Skip to content

The docs should also say infer_variance parameter with typing.ParamSpec explanation #145521

@hyperkai

Description

@hyperkai

Documentation

*Notes:

  • Python 3.14.3

infer_variance parameter is implemented for typing.ParamSpec according to the source code as shown below:

...
        if sys.version_info >= (3, 13):
            def __new__(
                cls,
                name: str,
                *,
                bound: Any | None = None,  # AnnotationForm
                contravariant: bool = False,
                covariant: bool = False,
                infer_variance: bool = False, # <- Here
                default: Any = ...,  # AnnotationForm
            ) -> Self: ...
...

And, Python interpreter doesn't give error for ParamSpec with infer_variance parameter as shown below:

                   # ↓ ↓ No error ↓ ↓
P = ParamSpec('P', infer_variance=True)

So, the docs should also say infer_variance parameter with typing.ParamSpec explanation as shown below:

class typing.ParamSpec(name, *, bound=None, covariant=False, contravariant=False, infer_variance=False, default=typing.NoDefault)

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