GH-96079 Fix missing field name for _AnnotatedAlias (#96080)

This commit is contained in:
Anh71me 2022-09-01 07:02:24 +08:00 committed by GitHub
parent 615537e62f
commit 0cd33e11fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View file

@ -7143,6 +7143,7 @@ def test_special_attrs(self):
typing.Self: 'Self',
# Subscribed special forms
typing.Annotated[Any, "Annotation"]: 'Annotated',
typing.Annotated[int, 'Annotation']: 'Annotated',
typing.ClassVar[Any]: 'ClassVar',
typing.Concatenate[Any, SpecialAttrsP]: 'Concatenate',
typing.Final[Any]: 'Final',

View file

@ -2101,7 +2101,7 @@ def __init__(self, origin, metadata):
if isinstance(origin, _AnnotatedAlias):
metadata = origin.__metadata__ + metadata
origin = origin.__origin__
super().__init__(origin, origin)
super().__init__(origin, origin, name='Annotated')
self.__metadata__ = metadata
def copy_with(self, params):
@ -2134,6 +2134,9 @@ def __getattr__(self, attr):
return 'Annotated'
return super().__getattr__(attr)
def __mro_entries__(self, bases):
return (self.__origin__,)
class Annotated:
"""Add context specific metadata to a type.

View file

@ -0,0 +1 @@
In :mod:`typing`, fix missing field ``name`` and incorrect ``__module__`` in _AnnotatedAlias.