@@ -975,16 +975,16 @@ These can be used as types in annotations using ``[]``, each having a unique syn
975
975
976
976
For example::
977
977
978
- def is_str_list(val: List [object]) -> TypeGuard[List [str]]:
978
+ def is_str_list(val: list [object]) -> TypeGuard[list [str]]:
979
979
'''Determines whether all objects in the list are strings'''
980
980
return all(isinstance(x, str) for x in val)
981
981
982
- def func1(val: List [object]):
982
+ def func1(val: list [object]):
983
983
if is_str_list(val):
984
- # Type of ``val`` is narrowed to ``List [str]``.
984
+ # Type of ``val`` is narrowed to ``list [str]``.
985
985
print(" ".join(val))
986
986
else:
987
- # Type of ``val`` remains as ``List [object]``.
987
+ # Type of ``val`` remains as ``list [object]``.
988
988
print("Not a list of strings!")
989
989
990
990
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
999
999
1000
1000
``TypeB `` need not be a narrower form of ``TypeA `` -- it can even be a
1001
1001
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.
1004
1004
The responsibility of writing type-safe type guards is left to the user.
1005
1005
1006
1006
``TypeGuard `` also works with type variables. For more information, see
@@ -2065,8 +2065,8 @@ Introspection helpers
2065
2065
.. class :: ForwardRef
2066
2066
2067
2067
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
2070
2070
a user, but may be used by introspection tools.
2071
2071
2072
2072
.. note ::
0 commit comments