8000 GH-96079 Fix missing field name for _AnnotatedAlias (#96080) · python/cpython@0cd33e1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0cd33e1

Browse files
authored
GH-96079 Fix missing field name for _AnnotatedAlias (#96080)
1 parent 615537e commit 0cd33e1

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

Lib/test/test_typing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7143,6 +7143,7 @@ def test_special_attrs(self):
71437143
typing.Self: 'Self',
71447144
# Subscribed special forms
71457145
typing.Annotated[Any, "Annotation"]: 'Annotated',
7146+
typing.Annotated[int, 'Annotation']: 'Annotated',
71467147
typing.ClassVar[Any]: 'ClassVar',
71477148
typing.Concatenate[Any, SpecialAttrsP]: 'Concatenate',
71487149
typing.Final[Any]: 'Final',

Lib/typing.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2101,7 +2101,7 @@ def __init__(self, origin, metadata):
21012101
if isinstance(origin, _AnnotatedAlias):
21022102
metadata = origin.__metadata__ + metadata
21032103
origin = origin.__origin__
2104-
super().__init__(origin, origin)
2104+
super().__init__(origin, origin, name='Annotated')
21052105
self.__metadata__ = metadata
21062106

21072107
def copy_with(self, params):
@@ -2134,6 +2134,9 @@ def __getattr__(self, attr):
21342134
return 'Annotated'
21352135
return super().__getattr__(attr)
21362136

2137+
def __mro_entries__(self, bases):
2138+
return (self.__origin__,)
2139+
21372140

21382141
class Annotated:
21392142
"""Add context specific metadata to a type.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
In :mod:`typing`, fix missing field ``name`` and incorrect ``__module__`` in _AnnotatedAlias.

0 commit comments

Comments
 (0)
0