Skip to content

Conversation

svlandeg
Copy link
Member

@svlandeg svlandeg commented Sep 19, 2025

Yesterday's release of Click 8.3.0 has introduced a new internal variable UNSET to differentiate between (truly) unset values and user-provided None values. As a consequence, the method Parameter.value_is_missing in click.core now checks for this UNSET value instead of for None.

This results in bugs when using the current Typer with Click 8.3.0+, because a required, unset parameter would be None in Typer (and not the new UNSET value) and would eventually get the default value instead of throwing an exception.

For instance:

@app.command()
def main(name: str):
    print(f"Hello {name}")

would result in a print "Hello None" when calling it without any arguments.

Potential solutions

  1. A quick fix would be to pin Typer to <8.3.0, but obviously that would only be temporary.
  2. This PR overwrites Click's value_is_missing function to revert it back to its functionality from before 8.3.0. This at least makes the test go green, and allows users to install Click 8.3.0+
  3. Rewrite Typer's core more fundamentally to exploit the new options of the UNSET value. This should also allow us to make different choices with respect to optional flags & flag values, cf 🗑️ Deprecate support for is_flag and flag_value parameters #987. Maybe with the new functionality in Click, we can restore some of that again. But it would require careful refactoring if we also want to continue support Click 8.2 and lower.

Proposal

At this point in time (right before the weekend 🙃) I suggest to merge this PR (option 2), close #1336 (option 1) and continue working on option 3 in the next few weeks.

@svlandeg svlandeg self-assigned this Sep 19, 2025
@svlandeg svlandeg added the bug Something isn't working label Sep 19, 2025
@svlandeg svlandeg changed the title Fix CI (WIP) 👽️ Fix CI to be compatible with Click 8.3.0 Sep 19, 2025
@svlandeg
Copy link
Member Author

This must be related to pallets/click#3030 and using the "UNSET" value...

@svlandeg svlandeg changed the title 👽️ Fix CI to be compatible with Click 8.3.0 👽️ Ensure compatibility with Click 8.3.0 Sep 19, 2025
@svlandeg svlandeg changed the title 👽️ Ensure compatibility with Click 8.3.0 👽️ Ensure compatibility with Click 8.3.0 by restoring the original value_is_missing function Sep 19, 2025
@svlandeg svlandeg marked this pull request as ready for review September 19, 2025 13:14
Copy link
Member

@tiangolo tiangolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the quick workaround and all the investigation and explanation, great as always! 🙌

I'll release this now in Typer 0.18.0 🚀

@tiangolo tiangolo merged commit 7a23d25 into fastapi:master Sep 19, 2025
25 checks passed
@svlandeg svlandeg deleted the fix/ci branch September 20, 2025 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants