-
-
Notifications
You must be signed in to change notification settings - Fork 672
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
Support for optional as UnionType (Python >= 3.10) #739
Conversation
7bba6a7
to
92d1179
Compare
Signed-off-by: Meir Komet <[email protected]>
92d1179
to
311dfaa
Compare
Also closes Another PR that also address this issue |
@@ -816,8 +822,9 @@ def get_click_param( | |||
is_tuple = False | |||
parameter_type: Any = None | |||
is_flag = None | |||
is_union_type = lenient_issubclass(type(main_type), UnionType) |
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.
Hi, I'm new to this kind of stuff, could you please clarify this for me please? From the variable name, it is a type
already, why do we need to convert it to type()
here? Is it just your preference or there are some edge cases being handled implicitly here?
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.
Hi, thanks for this PR!
There's a few other PRs that address the same issue, of which I think #548 would be the prime candidate to merge. That PR uses existing functionality such as utils.needs_py310
and ._typing.is_union
. If we merge #548, I think we can go ahead and close this one.
I'll leave the final decision with Tiangolo though.
This resolves the issue #533