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

fix: Support nested Annotated types #536

Merged
merged 3 commits into from
Feb 24, 2023

Conversation

hanjinliu
Copy link
Contributor

Fixes #535 .

get_args returns multiple options if Annotated is nested. We can also easily support annotated-types in the future because it also uses multiple options like Annotated[int, Gt(3), Lt(10)] (raises a TypeError for now).

@codecov
Copy link

codecov bot commented Feb 24, 2023

Codecov Report

Base: 89.65% // Head: 89.63% // Decreases project coverage by -0.02% ⚠️

Coverage data is based on head (b370b62) compared to base (9c36f9a).
Patch coverage: 80.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #536      +/-   ##
==========================================
- Coverage   89.65%   89.63%   -0.02%     
==========================================
  Files          37       37              
  Lines        4417     4420       +3     
==========================================
+ Hits         3960     3962       +2     
- Misses        457      458       +1     
Impacted Files Coverage Δ
src/magicgui/signature.py 95.18% <80.00%> (-1.07%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

# nested Annotated type results in multiple dicts.
annotation, *anno_options = get_args(annotation)
for opt in anno_options:
if not isinstance(opt, dict):
Copy link
Member

Choose a reason for hiding this comment

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

hmm... was I doing this when it worked before? I'm not sure I want to prevent people from using Annotated for any other reason.

Copy link
Member

Choose a reason for hiding this comment

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

Eh, I guess I'm already preventing it 😂 let's go with it!

@tlambert03 tlambert03 merged commit 9b66e92 into pyapp-kit:main Feb 24, 2023
@tlambert03 tlambert03 changed the title Support nested Annotated types fix: Support nested Annotated types Feb 27, 2023
@tlambert03 tlambert03 added the bug Something isn't working label Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot use nested Annotated type
2 participants