You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ python demo3.py
Widget(spam=A(name='Hormel'), eggs=B(name='Farm Fresh'))
$ mypy demo3.py
demo3.py:33: error: Argument 2 has incompatible type "Callable[[Any, Type[T]], T]"; expected "Callable[[Any, Type[T]], A]"
demo3.py:34: error: Argument 2 has incompatible type "Callable[[Any, Type[T]], T]"; expected "Callable[[Any, Type[T]], B]"
Found 2 errors in 1 file (checked 1 source file)
Changing the signature on register_structure_hook from self, cl: Type[T], func: Callable[[Any, Type[V]], T] to self, cl: Type[T], func: Callable[[Any, Type[T]], T] resolves this and I'm not sure why the latter is wrong but I'm probably missing some subtlety.
The text was updated successfully, but these errors were encountered:
Hm, I think we would be ok with changing the type signature to self, cl: Type[T], func: Callable[[Any, Type[T]], T]. I don't remember the reason for using a different type var here.
Description
I might be misspecifying it, but I'm not sure how to register a generic structure hook function that can return more than one type.
mypy didn't complain about cattrs 1.0 and it continues to execute fine.
What I Did
Changing the signature on
register_structure_hook
fromself, cl: Type[T], func: Callable[[Any, Type[V]], T]
toself, cl: Type[T], func: Callable[[Any, Type[T]], T]
resolves this and I'm not sure why the latter is wrong but I'm probably missing some subtlety.The text was updated successfully, but these errors were encountered: