What type `bound` parameter of `typing.TypeVar` accepts should be explained more clearly
Open
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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