python / python/cpython

What type `bound` parameter of `typing.TypeVar` accepts should be explained more clearly

Open
#145,524 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs topic-typing triaged
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Documentation

*Notes:

  • Python 3.14.3

For T and A, what type is accepted is clearly explained in the example of typing.TypeVar while for S isn't explained clearly even though str itself is also accepted as shown below:

T = TypeVar('T')  # Can be anything
S = TypeVar('S', bound=str)  # Can be any subtype of str <- Here
A = TypeVar('A', str, bytes)  # Must be exactly str or bytes

So, S should be explained more clearly as shown below:

S = TypeVar('S', bound=str)  # Can be str or any subtype of str
Linked PRs
  • gh-145525

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the typing.TypeVar documentation and its T, S, and A examples linked in the issue. Clarify the bound=str example so it explicitly states that str itself and its subtypes are accepted, then check the rendered documentation for consistent wording.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.