Typer expects default value for CustomClass as string instead of class itself, which breaks typing and breaks using this function without typer #720
Replies: 2 comments 1 reply
-
I was recently bitten by a similar issue, providing |
Beta Was this translation helpful? Give feedback.
-
I can see how this construction is preventing a proper type check, as the
How would you attempt to fix this? |
Beta Was this translation helpful? Give feedback.
-
First Check
Commit to Help
Example Code
Description
So example code above works fine, but, it doesn't type check properly because main supposed to accept datetime.date, and it's default is string.
Also, if I try to run function main without typer(a big feature for typer that it's usually possible), this argument will get str
If I change it to
which type-checks fine, I'll get
TypeError: strptime() argument 1 must be str, not datetime.date
because typer expects that I give it a string, not datetime and calls parser on itOperating System
Linux, Windows, macOS, Other
Operating System Details
any
Typer Version
0.9.0
Python Version
Python 3.11.4
Additional Context
I think I'm ready to (try to) contribute this as PR, if this is considered worth fixing
Beta Was this translation helpful? Give feedback.
All reactions