-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Note this is in python 3.9 where typing.Annotated exists. I'm using pytypes from
pip install git+https://github.com/Stewori/pytypes.git
import pytypes
import typing
CT = typing.TypeVar('CT')
class Variable(typing.Generic[CT]):
pass
pytypes.is_of_type(Variable[int](), Variable[int]) # returns True as expected
pytypes.is_of_type(Variable[int](), typing.Annotated[Variable[int], 'a']) # returns False unexpected
pytypes.is_of_type(3, typing.Annotated[int, 'a']) # returns True as expected
After stepping through the is_of_type function I end up in _issubclass_Generic.
I suspect there is some issue in _issubclass_Generic here:
elif origin is not None and \
_issubclass(_origin(subclass), origin, bound_Generic, bound_typevars,
bound_typevars_readonly, follow_fwd_refs, _recursion_check):
takes an origin of the subclass so Variable[int] turns into Variable and origin of typing.Annotated is Variable[Int] so clearly _issubclass(Variable, Variable[int]) will not go through later parts of the function will basically all return False, so I think this is the place that needs to work.
Anyways let me know if I can be of any more help in resolving this issue.
Metadata
Metadata
Assignees
Labels
No labels