Skip to content

Commit 55c5305

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

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
@@ -1609,11 +1609,11 @@ without the dedicated syntax, as documented below.
16091609
class Sequence[T]: # T is a TypeVar
16101610
...
16111611

1612-
This syntax can also be used to create bound and constrained type
1612+
This syntax can also be used to create bounded and constrained type
16131613
variables::
16141614

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

16181618

16191619
class StrOrBytesSequence[A: (str, bytes)]: # A is a TypeVar constrained to str or bytes
@@ -1646,8 +1646,8 @@ without the dedicated syntax, as documented below.
16461646
"""Add two strings or bytes objects together."""
16471647
return x + y
16481648

1649-
Note that type variables can be *bound*, *constrained*, or neither, but
1650-
cannot be both bound *and* constrained.
1649+
Note that type variables can be *bounded*, *constrained*, or neither, but
1650+
cannot be both bounded *and* constrained.
16511651

16521652
The variance of type variables is inferred by type checkers when they are created
16531653
through the :ref:`type parameter syntax <type-params>` or when
@@ -1657,8 +1657,8 @@ without the dedicated syntax, as documented below.
16571657
By default, manually created type variables are invariant.
16581658
See :pep:`484` and :pep:`695` for more details.
16591659

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

16641664
x = print_capitalized('a string')
@@ -1672,8 +1672,8 @@ without the dedicated syntax, as documented below.
16721672

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

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

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

17181718
.. attribute:: __bound__
17191719

1720-
The bound of the type variable, if any.
1720+
The upper bound of the type variable, if any.
17211721

17221722
.. versionchanged:: 3.12
17231723

@@ -1903,7 +1903,7 @@ without the dedicated syntax, as documented below.
19031903
return x + y
19041904

19051905
Without ``ParamSpec``, the simplest way to annotate this previously was to
1906-
use a :class:`TypeVar` with bound ``Callable[..., Any]``. However this
1906+
use a :class:`TypeVar` with upper bound ``Callable[..., Any]``. However this
19071907
causes two problems:
19081908

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

0 commit comments

Comments
 (0)