Skip to content

Commit 7ab72d7

Browse files
Add back _AnnotatedAlias (#587)
Fixes #586
1 parent 7cfb2c0 commit 7ab72d7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/test_typing_extensions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5251,6 +5251,11 @@ def test_nested_annotated_with_unhashable_metadata(self):
52515251
self.assertEqual(X.__origin__, List[Annotated[str, {"unhashable_metadata"}]])
52525252
self.assertEqual(X.__metadata__, ("metadata",))
52535253

5254+
def test_compatibility(self):
5255+
# Test that the _AnnotatedAlias compatibility alias works
5256+
self.assertTrue(hasattr(typing_extensions, "_AnnotatedAlias"))
5257+
self.assertIs(typing_extensions._AnnotatedAlias, typing._AnnotatedAlias)
5258+
52545259

52555260
class GetTypeHintsTests(BaseTestCase):
52565261
def test_get_type_hints(self):

src/typing_extensions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4095,7 +4095,7 @@ def evaluate_forward_ref(
40954095
)
40964096

40974097

4098-
# Aliases for items that have always been in typing.
4098+
# Aliases for items that are in typing in all supported versions.
40994099
# Explicitly assign these (rather than using `from typing import *` at the top),
41004100
# so that we get a CI error if one of these is deleted from typing.py
41014101
# in a future version of Python
@@ -4136,3 +4136,6 @@ def evaluate_forward_ref(
41364136
cast = typing.cast
41374137
no_type_check = typing.no_type_check
41384138
no_type_check_decorator = typing.no_type_check_decorator
4139+
# This is private, but it was defined by typing_extensions for a long time
4140+
# and some users rely on it.
4141+
_AnnotatedAlias = typing._AnnotatedAlias

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy