Skip to content

Commit a98b273

Browse files
Replace usage of List[...] with list[...] in typing docs (GH-28821)
The ``List[...]`` form is deprecated since 3.9.
1 parent b108db6 commit a98b273

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Doc/library/typing.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -975,16 +975,16 @@ These can be used as types in annotations using ``[]``, each having a unique syn
975975

976976
For example::
977977

978-
def is_str_list(val: List[object]) -> TypeGuard[List[str]]:
978+
def is_str_list(val: list[object]) -> TypeGuard[list[str]]:
979979
'''Determines whether all objects in the list are strings'''
980980
return all(isinstance(x, str) for x in val)
981981

982-
def func1(val: List[object]):
982+
def func1(val: list[object]):
983983
if is_str_list(val):
984-
# Type of ``val`` is narrowed to ``List[str]``.
984+
# Type of ``val`` is narrowed to ``list[str]``.
985985
print(" ".join(val))
986986
else:
987-
# Type of ``val`` remains as ``List[object]``.
987+
# Type of ``val`` remains as ``list[object]``.
988988
print("Not a list of strings!")
989989

990990
If ``is_str_list`` is a class or instance method, then the type in
@@ -999,8 +999,8 @@ These can be used as types in annotations using ``[]``, each having a unique syn
999999

10001000
``TypeB`` need not be a narrower form of ``TypeA`` -- it can even be a
10011001
wider form. The main reason is to allow for things like
1002-
narrowing ``List[object]`` to ``List[str]`` even though the latter
1003-
is not a subtype of the former, since ``List`` is invariant.
1002+
narrowing ``list[object]`` to ``list[str]`` even though the latter
1003+
is not a subtype of the former, since ``list`` is invariant.
10041004
The responsibility of writing type-safe type guards is left to the user.
10051005

10061006
``TypeGuard`` also works with type variables. For more information, see
@@ -2065,8 +2065,8 @@ Introspection helpers
20652065
.. class:: ForwardRef
20662066

20672067
A class used for internal typing representation of string forward references.
2068-
For example, ``List["SomeClass"]`` is implicitly transformed into
2069-
``List[ForwardRef("SomeClass")]``. This class should not be instantiated by
2068+
For example, ``list["SomeClass"]`` is implicitly transformed into
2069+
``list[ForwardRef("SomeClass")]``. This class should not be instantiated by
20702070
a user, but may be used by introspection tools.
20712071

20722072
.. note::

0 commit comments

Comments
 (0)