Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-126543: Docs: change "bound type var" to "bounded" when used in the context of the 'bound' kw argument to TypeVar #126584

Merged
merged 5 commits into from
Nov 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1726,10 +1726,10 @@ without the dedicated syntax, as documented below.
class Sequence[T]: # T is a TypeVar
...

This syntax can also be used to create bound and constrained type
This syntax can also be used to create bounded and constrained type
variables::

class StrSequence[S: str]: # S is a TypeVar bound to str
class StrSequence[S: str]: # S is a TypeVar bounded by str
fofoni marked this conversation as resolved.
Show resolved Hide resolved
...


Expand Down Expand Up @@ -1763,8 +1763,8 @@ without the dedicated syntax, as documented below.
"""Add two strings or bytes objects together."""
return x + y

Note that type variables can be *bound*, *constrained*, or neither, but
cannot be both bound *and* constrained.
Note that type variables can be *bounded*, *constrained*, or neither, but
cannot be both bounded *and* constrained.

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

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

x = print_capitalized('a string')
Expand All @@ -1789,7 +1789,7 @@ without the dedicated syntax, as documented below.

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

Type variables can be bound to concrete types, abstract types (ABCs or
Type variables can be bounded by concrete types, abstract types (ABCs or
protocols), and even unions of types::
fofoni marked this conversation as resolved.
Show resolved Hide resolved

# Can be anything with an __abs__ method
Expand Down
Loading