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
I expected types to be promoted to sub-types within an issubclass block, the same as instances within an isinstance block, but type-checking the following code results in the error Type[Vehicle] has no attribute "wheels":
Yeah, this would be a reasonable thing to support, though you can currently work around the limitation pretty easily by using cast(Type[Subclass], x) after the issubclass check. Example:
Activity
ilevkivskyi commentedon Feb 26, 2017
This would be an interesting feature. Also I think the implementation would be straightforward, since
isinstanceis already understood by mypy.JukkaL commentedon Feb 27, 2017
Yeah, this would be a reasonable thing to support, though you can currently work around the limitation pretty easily by using
cast(Type[Subclass], x)after theissubclasscheck. Example: