mirror of https://github.com/python/cpython
GH-96079 Fix missing field name for _AnnotatedAlias (#96080)
This commit is contained in:
parent
615537e62f
commit
0cd33e11fe
|
@ -7143,6 +7143,7 @@ class SpecialAttrsTests(BaseTestCase):
|
||||||
typing.Self: 'Self',
|
typing.Self: 'Self',
|
||||||
# Subscribed special forms
|
# Subscribed special forms
|
||||||
typing.Annotated[Any, "Annotation"]: 'Annotated',
|
typing.Annotated[Any, "Annotation"]: 'Annotated',
|
||||||
|
typing.Annotated[int, 'Annotation']: 'Annotated',
|
||||||
typing.ClassVar[Any]: 'ClassVar',
|
typing.ClassVar[Any]: 'ClassVar',
|
||||||
typing.Concatenate[Any, SpecialAttrsP]: 'Concatenate',
|
typing.Concatenate[Any, SpecialAttrsP]: 'Concatenate',
|
||||||
typing.Final[Any]: 'Final',
|
typing.Final[Any]: 'Final',
|
||||||
|
|
|
@ -2101,7 +2101,7 @@ class _AnnotatedAlias(_NotIterable, _GenericAlias, _root=True):
|
||||||
if isinstance(origin, _AnnotatedAlias):
|
if isinstance(origin, _AnnotatedAlias):
|
||||||
metadata = origin.__metadata__ + metadata
|
metadata = origin.__metadata__ + metadata
|
||||||
origin = origin.__origin__
|
origin = origin.__origin__
|
||||||
super().__init__(origin, origin)
|
super().__init__(origin, origin, name='Annotated')
|
||||||
self.__metadata__ = metadata
|
self.__metadata__ = metadata
|
||||||
|
|
||||||
def copy_with(self, params):
|
def copy_with(self, params):
|
||||||
|
@ -2134,6 +2134,9 @@ class _AnnotatedAlias(_NotIterable, _GenericAlias, _root=True):
|
||||||
return 'Annotated'
|
return 'Annotated'
|
||||||
return super().__getattr__(attr)
|
return super().__getattr__(attr)
|
||||||
|
|
||||||
|
def __mro_entries__(self, bases):
|
||||||
|
return (self.__origin__,)
|
||||||
|
|
||||||
|
|
||||||
class Annotated:
|
class Annotated:
|
||||||
"""Add context specific metadata to a type.
|
"""Add context specific metadata to a type.
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
In :mod:`typing`, fix missing field ``name`` and incorrect ``__module__`` in _AnnotatedAlias.
|
Loading…
Reference in New Issue