Skip to content
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

🐛 Add support for an argument of type Optional[Tuple] and default value None #757

Merged
merged 9 commits into from
Apr 7, 2024

Conversation

Asthestarsfalll
Copy link
Contributor

Support optional tuples like this:

from typing import Optional, Tuple
import typer

def main(arg: Optional[Tuple[int]] = None):
    pass

typer.run(main)

@svlandeg svlandeg added feature New feature, enhancement or request p3 labels Mar 23, 2024
@svlandeg svlandeg added bug Something isn't working p2 and removed feature New feature, enhancement or request p3 labels Mar 28, 2024
Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

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

I relabeled this as a bug, as it feels like this is functionality that you'd expect to work, but currently doesn't on master. The fix seems correct to me, and I've slightly rewritten the unit test to be even more in line with the preceding test_optional().

Thanks for your contribution!

@svlandeg svlandeg changed the title Support optional tuples 🐛 Add support for an argument of type Optional[Tuple] and default value None Mar 29, 2024
@tiangolo tiangolo changed the title 🐛 Add support for an argument of type Optional[Tuple] and default value None 🐛 Add support for an argument of type Optional[Tuple] and default value None Apr 7, 2024
@tiangolo
Copy link
Member

tiangolo commented Apr 7, 2024

Great, thanks for your contribution @Asthestarsfalll! 🚀

And thanks for the help @svlandeg! 🙇 🍰

@tiangolo tiangolo merged commit a0209aa into fastapi:master Apr 7, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants