10000 gh-124269: Simplify `typing.Annotated` docs by StanFromIreland · Pull Request #130770 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-124269: Simplify typing.Annotated docs #130770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 14, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from Jelle
  • Loading branch information
StanFromIreland committed Mar 3, 2025
commit f54a3688af3f39aad3082e26190356abec9518ca
3 changes: 1 addition & 2 deletions Doc/library/typing.rst
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,6 @@ These can be used as types in annotations. They all support subscription using
T1 = Annotated[int, ValueRange(-10, 5)]
T2 = Annotated[T1, ValueRange(-20, 3)]

``Annotated`` must be subscripted with at least two arguments.
The first argument to ``Annotated`` must be a valid type. Multiple metadata
elements can be supplied as ``Annotated`` supports variadic arguments. The
order of the metadata elements is preserved and matters for equality checks::
Expand Down Expand Up @@ -1418,7 +1417,7 @@ These can be used as types in annotations. They all support subscription using

type Variadic[*Ts] = Annotated[*Ts, Ann1] = Annotated[T1, T2, T3, ..., Ann1] # NOT valid

where ``T1``, ``T2``,... are :class:`TypeVars <TypeVar>`. This is invalid as
where ``T1``, ``T2``, ... are :class:`TypeVars <TypeVar>`. This is invalid as
only one type should be passed to Annotated.

By default, :func:`get_type_hints` strips the metadata from annotations.
Expand Down
Loading
0