[doc] Use list[int] instead of List[int] (etc.) in a few more places (GH-22524)
This changes a few occurrences left behind by #22340. Automerge-Triggered-By: @gvanrossum
This commit is contained in:
parent
fb0a4651f1
commit
7f54e563dc
|
@ -188,7 +188,7 @@ Module-level decorators, classes, and functions
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class C:
|
class C:
|
||||||
mylist: List[int] = field(default_factory=list)
|
mylist: list[int] = field(default_factory=list)
|
||||||
|
|
||||||
c = C()
|
c = C()
|
||||||
c.mylist += [1, 2, 3]
|
c.mylist += [1, 2, 3]
|
||||||
|
@ -301,7 +301,7 @@ Module-level decorators, classes, and functions
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class C:
|
class C:
|
||||||
mylist: List[Point]
|
mylist: list[Point]
|
||||||
|
|
||||||
p = Point(10, 20)
|
p = Point(10, 20)
|
||||||
assert asdict(p) == {'x': 10, 'y': 20}
|
assert asdict(p) == {'x': 10, 'y': 20}
|
||||||
|
|
|
@ -661,7 +661,7 @@ These can be used as types in annotations using ``[]``, each having a unique syn
|
||||||
and should not be set on instances of that class. Usage::
|
and should not be set on instances of that class. Usage::
|
||||||
|
|
||||||
class Starship:
|
class Starship:
|
||||||
stats: ClassVar[Dict[str, int]] = {} # class variable
|
stats: ClassVar[dict[str, int]] = {} # class variable
|
||||||
damage: int = 10 # instance variable
|
damage: int = 10 # instance variable
|
||||||
|
|
||||||
:data:`ClassVar` accepts only types and cannot be further subscribed.
|
:data:`ClassVar` accepts only types and cannot be further subscribed.
|
||||||
|
@ -774,10 +774,10 @@ These can be used as types in annotations using ``[]``, each having a unique syn
|
||||||
* ``Annotated`` can be used with nested and generic aliases::
|
* ``Annotated`` can be used with nested and generic aliases::
|
||||||
|
|
||||||
T = TypeVar('T')
|
T = TypeVar('T')
|
||||||
Vec = Annotated[List[Tuple[T, T]], MaxLen(10)]
|
Vec = Annotated[list[tuple[T, T]], MaxLen(10)]
|
||||||
V = Vec[int]
|
V = Vec[int]
|
||||||
|
|
||||||
V == Annotated[List[Tuple[int, int]], MaxLen(10)]
|
V == Annotated[list[tuple[int, int]], MaxLen(10)]
|
||||||
|
|
||||||
.. versionadded:: 3.9
|
.. versionadded:: 3.9
|
||||||
|
|
||||||
|
@ -1540,7 +1540,7 @@ Functions and decorators
|
||||||
def process(response: None) -> None:
|
def process(response: None) -> None:
|
||||||
...
|
...
|
||||||
@overload
|
@overload
|
||||||
def process(response: int) -> Tuple[int, str]:
|
def process(response: int) -> tuple[int, str]:
|
||||||
...
|
...
|
||||||
@overload
|
@overload
|
||||||
def process(response: bytes) -> str:
|
def process(response: bytes) -> str:
|
||||||
|
@ -1679,8 +1679,8 @@ Introspection helpers
|
||||||
.. class:: ForwardRef
|
.. class:: ForwardRef
|
||||||
|
|
||||||
A class used for internal typing representation of string forward references.
|
A class used for internal typing representation of string forward references.
|
||||||
For example, ``List["SomeClass"]`` is implicitly transformed into
|
For example, ``list["SomeClass"]`` is implicitly transformed into
|
||||||
``List[ForwardRef("SomeClass")]``. This class should not be instantiated by
|
``list[ForwardRef("SomeClass")]``. This class should not be instantiated by
|
||||||
a user, but may be used by introspection tools.
|
a user, but may be used by introspection tools.
|
||||||
|
|
||||||
Constant
|
Constant
|
||||||
|
|
Loading…
Reference in New Issue