Skip to content

Commit 5d61ab1

Browse files
committed
Explain why alias is not flattened
1 parent d8ce20a commit 5d61ab1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Doc/library/typing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ These can be used as types in annotations. They all support subscription using
14031403
]
14041404

14051405
However, this does not apply to ``Annotated`` types referenced through a type
1406-
alias::
1406+
alias, to avoid forcing evaluation of the underlying :class:`TypeAliasType`::
14071407

14081408
type From3To10[T] = Annotated[T, ValueRange(3, 10)]
14091409
assert Annotated[From3To10[int], ctype("char")] != Annotated[

Lib/typing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2240,7 +2240,8 @@ def Annotated(self, *params):
22402240
assert Annotated[Annotated[T, Ann1, Ann2], Ann3] == Annotated[T, Ann1, Ann2, Ann3]
22412241
22422242
However, this does not apply to Annotated types referenced through
2243-
a type alias::
2243+
a type alias, to avoid forcing evaluation of the underlying
2244+
TypeAliasType::
22442245
22452246
type A[T] = Annotated[T, Ann1, Ann2]
22462247
assert Annotated[A[T], Ann3] != Annotated[T, Ann1, Ann2, Ann3]

0 commit comments

Comments
 (0)