Skip to content

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

Description

@hyperkai

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

Activity

  1. added
    docs
    on Mar 5, 2026
  2. picnixz commented on Mar 5, 2026

    @picnixz
    Member

    T is a subtype of itself so I don't think it should be changed.

  3. added
    pending
    on Mar 5, 2026
  4. picnixz commented on Mar 5, 2026

    @picnixz
    Member

    Ok, nvm, Alex was ok with the PR.

  5. added
    triaged
    and removed
    pending
    on Mar 5, 2026
  6. added a commit that references this issue on Nov 28, 2026
  7. added a commit that references this issue on Nov 28, 2026
  8. added a commit that references this issue on Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docstopic-typingtriaged

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions