Skip to content

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

@hyperkai

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions