8000 [3.13] gh-126543: Docs: change "bound type var" to "bounded" when use… · python/cpython@3d8f549 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3d8f549

Browse files
[3.13] gh-126543: Docs: change "bound type var" to "bounded" when used in the context of the 'bound' kw argument to TypeVar (GH-126584) (#126657)
(cherry picked from commit 434b297) Co-authored-by: Pedro Fonini <fonini@protonmail.ch>
1 parent 4567ad2 commit 3d8f549

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Doc/library/typing.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,11 +1726,11 @@ without the dedicated syntax, as documented below.
17261726
class Sequence[T]: # T is a TypeVar
17271727
...
17281728

1729-
This syntax can also be used to create bound and constrained type
1729+
This syntax can also be used to create bounded and constrained type
17301730
variables::
17311731

1732-
class StrSequence[S: str]: # S is a TypeVar bound to str
1733-
...
1732+
class StrSequence[S: str]: # S is a TypeVar with a `str` upper bound;
1733+
... # we can say that S is "bounded by `str`"
17341734

17351735

17361736
class StrOrBytesSequence[A: (str, bytes)]: # A is a TypeVar constrained to str or bytes
@@ -1763,8 +1763,8 @@ without the dedicated syntax, as documented below.
17631763
"""Add two strings or bytes objects together."""
17641764
return x + y
17651765

1766-
Note that type variables can be *bound*, *constrained*, or neither, but
1767-
cannot be both bound *and* constrained.
1766+
Note that type variables can be *bounded*, *constrained*, or neither, but
1767+
cannot be both bounded *and* constrained.
17681768

17691769
The variance of type variables is inferred by type checkers when they are created
17701770
through the :ref:`type parameter syntax <type-params>` or when
@@ -1774,8 +1774,8 @@ without the dedicated syntax, as documented below.
17741774
By default, manually created type variables are invariant.
17751775
See :pep:`484` and :pep:`695` for more details.
17761776

1777-
Bound type variables and constrained type variables have different
1778-
semantics in several important ways. Using a *bound* type variable means
1777+
Bounded type variables and constrained type variables have different
1778+
semantics in several important ways. Using a *bounded* type variable means
17791779
that the ``TypeVar`` will be solved using the most specific type possible::
17801780

17811781
x = print_capitalized('a string')
@@ -1789,8 +1789,8 @@ without the dedicated syntax, as documented below.
17891789

17901790
z = print_capitalized(45) # error: int is not a subtype of str
17911791

1792-
Type variables can be bound to concrete types, abstract types (ABCs or
1793-
protocols), and even unions of types::
1792+
The upper bound of a type variable can be a concrete type, abstract type
1793+
(ABC or Protocol), or even a union of types::
17941794

17951795
# Can be anything with an __abs__ method
17961796
def print_abs[T: SupportsAbs](arg: T) -> None:
@@ -1834,7 +1834,7 @@ without the dedicated syntax, as documented below.
18341834

18351835
.. attribute:: __bound__
18361836

1837-
The bound of the type variable, if any.
1837+
The upper bound of the type variable, if any.
18381838

18391839
.. versionchanged:: 3.12
18401840

@@ -2060,7 +2060,7 @@ without the dedicated syntax, as documented below.
20602060
return x + y
20612061

20622062
Without ``ParamSpec``, the simplest way to annotate this previously was to
2063-
use a :class:`TypeVar` with bound ``Callable[..., Any]``. However this
2063+
use a :class:`TypeVar` with upper bound ``Callable[..., Any]``. However this
20642064
causes two problems:
20652065

20662066
1. The type checker can't type check the ``inner`` function because

0 commit comments

Comments
 (0)
0