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 disagree that it is a bug that you can subclass Annotated[int, ...]. I think you're meant to be able to use Annotated[int, ...] at runtime at all sites where you could use int. Why should code like this be disallowed?
Activity
sobolevn commentedon Sep 12, 2022
Related: #96080
This PR introduced explicit
__mro_entries__to_AnnotatedAlias.sobolevn commentedon Sep 12, 2022
But,
Annotatedwas subclassable even in3.10.0:sobolevn commentedon Sep 12, 2022
Looks like there's a test for quite the opposite: https://github.com/python/cpython/blame/53a54b781d1f05f2d0b40ce88b3da92d5d23e9d2/Lib/test/test_typing.py#L6713-L6717
It ensures that
Annotatedcan be subclassed. Related: #27841AlexWaygood commentedon Sep 12, 2022
I disagree that it is a bug that you can subclass
Annotated[int, ...]. I think you're meant to be able to useAnnotated[int, ...]at runtime at all sites where you could useint. Why should code like this be disallowed?This works fine, and I don't see why the cases should be treated differently:
AlexWaygood commentedon Sep 12, 2022
In any case, it would surely be backwards-incompatible to change this behaviour now?
sobolevn commentedon Sep 12, 2022
Yes, changing this will be backward incompatible. Even type-checkers can understand this:
So, it probably should stay as-is.