-
-
Notifications
You must be signed in to change notification settings - Fork 826
✨ Support typing.Literal to define a set of predefined choices
#429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
Any updates on merging this? @tiangolo |
|
Upvote for this PR, as using Literal is more succinct then using enum. |
atmartinez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is the possibility to import Literal from typing_extensions to allow this to work for 3.6 (since Typer still says it support it despite being EOL) and 3.7 as well. This may be a moot consideration soon though since 3.7 goes EOL in June 2023 as well if there are any plans to drop unsupported Python versions at some point.
This may require adding a specific dependency for typing_extensions, but it's currently being installed by another dep regardless from some of the CI runs I checked for 3.6+ 4.1-4.4 depending on the Python version.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
Update:
|
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
I was really hoping this got merged for the latest release 2 weeks ago 👀 |
tiangolo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment was marked as outdated.
This comment was marked as outdated.
typing.Literal to define a set of predefined choices
|
📝 Docs preview for commit d876108 at: https://b44fab2b.typertiangolo.pages.dev Modified Pages |
Copied PR #174 from someone who deleted their account because I think it's worth reopening this PR and adding this functionality to typer.
Original PR message: