Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
Closed
Labels
Description
You can subclass Annotated[int, "meta"]:
>>>importtyping>>>classSome(typing.Annotated[int, 'meta']): ... ... >>>Some.__mro__ (<class'__main__.Some'>, <class'int'>, <class'object'>)But, here are a couple of problems:
- All metadata is lost: so, no reason to use
Annotatedin the first place - https://peps.python.org/pep-0593/ never mentions this use-case
- We assume that
Annotatedcannot be subclassed: https://github.com/python/cpython/blame/53a54b781d1f05f2d0b40ce88b3da92d5d23e9d2/Lib/test/test_typing.py#L6562-L6565 here
I think that Annotated should not be subclasses and this is a bug.
The PR is incoming :)
I found this while working on #96769