Skip to content
Open
Changes from all commits
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
2 changes: 1 addition & 1 deletion Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,7 @@ without the dedicated syntax, as documented below.
However, if desired, reusable type variables can also be constructed manually, like so::

T = TypeVar('T') # Can be anything
S = TypeVar('S', bound=str) # Can be any subtype of str
S = TypeVar('S', bound=str) # Can be str or any subtype of str
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this wording, it looks like str is not a subtype of itself. Should we make it more clearly a clarification/note?

Suggested change
S = TypeVar('S', bound=str) # Can be str or any subtype of str
S = TypeVar('S', bound=str) # Can be any subtype of str (including exact str)

A = TypeVar('A', str, bytes) # Must be exactly str or bytes

Type variables exist primarily for the benefit of static type
Expand Down
Loading