-
-
Notifications
You must be signed in to change notification settings - Fork 671
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
PEP 604 Support #348
Comments
I'm thinking if you can do this |
+1 |
Could this be more of a Pydantic issue? |
@navhits I'm not exactly sure what you mean. Pydantic supports PEP 604 type hints. |
If that's the case, then try building from python3.10 branch. In my understanding 604 is a 3.10 focussed enhancement. |
I've been on that version since march. |
Seems this is still broken as of 0.7.0, even though that release is supposed to support Python 3.11 (and therefore I assumed these new type annotations included with Python3.10) |
Yeps, running into this as well. As we have |
Make them standalone types and pyupgrade will not change it. Or exclude the file from pyupgrade (your CLI interface is separated from the rest of your app, right?). PathOrNone = Path | None
def main(output: PathOrNone):
typer.guess_name(f"Hello {name}") |
Last I tried, making them standalone types would still give errors in |
Sorry, bad example, I just woke up. 😂 PathOrNone = Optional[Path]
def main(output: PathOrNone):
typer.guess_name(f"Hello {name}") pyupgrade should not change |
Nice one, thanks! |
Since the PR doesn't link to this issue, I'll link it here. This PR appears to be trying to fix this issue: |
For visibility, the current open PR for this issue is |
Pydantic also has this issue and supports the union type as of pydantic 2.5. Not sure if this requires typer to support pydantic >=2.5? |
Thanks everyone for the feedback! ☕ This should have been fixed by #548 It is now available in Typer |
First Check
Commit to Help
Example Code
Description
Using an argument with the type of
pathlib.Path | None
(as per PEP 604) raise the error:Wanted Solution
| None
types should work instead of having to need to useOptional[]
.Wanted Code
Alternatives
No response
Operating System
Linux
Operating System Details
No response
Typer Version
0.4.0
Python Version
3.10.1
Additional Context
No response
The text was updated successfully, but these errors were encountered: