-
-
Notifications
You must be signed in to change notification settings - Fork 829
✨ Support Date parameter type (#94) #326
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
|
bump. this is what I stumbled upon today and would be nice to have |
|
This pull request has a merge conflict that needs to be resolved. |
svlandeg
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.
Can you clarify why you'd need/want this, given that Typer already supports datetime?
|
|
||
| ```Python hl_lines="2 7 8 9" | ||
| {!../docs_src/parameter_types/date/tutorial001.py!} | ||
| ``` |
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.
Just a quick note here that if we do want to progress with this PR at some point, the docs should be updated with the new format, and using Typer() explicitely in the tutorial examples.
|
Long time no see ! 👋 I had a CLI app with a Indeed, users may be confused to see that However, time has passed and Click custom types support has been been added to Typer: https://typer.tiangolo.com/tutorial/parameter-types/custom-types/#type-parser Regarding this newly (2023) addition, I believe we can close this PR. Users seeking a Thanks for your help ! |
Implements an extra click type
Date, based on built-inclick.DateTimeto enable Typer support for Pythondatetime.date.This approach could unlock others unsupported Python build-in types, even if the best solution would be to implement them directly inside Click.
Another approach - more complex but more flexible - would be to autorise Type's users to define their own extra Click types at Typer's app level using a mapping "annotation -> click type implementation":
However, this would require more serious discussion and I'll be happy to open a dedicated issue if someone is interested 🙂
Most changes in this PR are tests / documentation related but I would like to say it was a pleasure to discover the powerful intrication between tests and documentation in place in this project 😃
This is well designed and very efficient to write 👏