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

Bug: Annotated types only work in function signatures #478

Closed
tlambert03 opened this issue Oct 25, 2022 · 0 comments · Fixed by #525
Closed

Bug: Annotated types only work in function signatures #478

tlambert03 opened this issue Oct 25, 2022 · 0 comments · Fixed by #525
Labels
bug Something isn't working

Comments

@tlambert03
Copy link
Member

Describe the bug

create_widget(annotation=Annotated[float, {'max': 5}])
File ~/dev/self/magicgui/magicgui/type_map.py:83, in match_type(tw)
     80 """Check simple type mappings."""
     81 _type = tw.outer_type_
---> 83 if _type in _SIMPLE_ANNOTATIONS:
     84     return _SIMPLE_ANNOTATIONS[_type], {}
     86 if _type is widgets.ProgressBar:

File ~/mambaforge/envs/magicgui/lib/python3.10/typing.py:1651, in _AnnotatedAlias.__hash__(self)
   1650 def __hash__(self):
-> 1651     return hash((self.__origin__, self.__metadata__))

TypeError: unhashable type: 'dict'

problem is that Annotated types are only parsed when members of function signatures...
This should be and will be fixed in the course of #474 ... and is another indication that magicgui is too centered on functions as the unit of input

@tlambert03 tlambert03 added the bug Something isn't working label Oct 25, 2022
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 a pull request may close this issue.

1 participant