Skip to content

The docstring of ParamSpec should show two examples with a list instead of a tuple #143089

@hyperkai

Description

@hyperkai

Bug report

Bug description:

*Memo:

  • mypy test.py
  • pyright test.py
  • mypy 1.19.1
  • pyright 1.1.407
  • Python 3.13.11
  • Windows 11

The docstring of ParamSpec shows two examples as shown below:

from typing import ParamSpec

print(help(ParamSpec))

type IntFuncDefault[**P = (int, str)] = Callable[P, int]

P = ParamSpec('P')
DefaultP = ParamSpec('DefaultP', default=(int, str))

But mypy gives the error because a tuple is set instead of a list as shown below:

*Memo:

  • pyright also gives error.
from typing import ParamSpec

                        # ↓ tuple  ↓
type IntFuncDefault[**P = (int, str)] = Callable[P, int] # Error

P = ParamSpec('P')                     # ↓ tuple  ↓
DefaultP = ParamSpec('DefaultP', default=(int, str)) # Error

error: The default argument to ParamSpec must be a list expression, ellipsis, or a ParamSpec

Actually, setting a list gets no error as shown below:

from typing import ParamSpec

                        # ↓  list  ↓
type IntFuncDefault[**P = [int, str]] = Callable[P, int] # No error

P = ParamSpec('P')                     # ↓  list  ↓
DefaultP = ParamSpec('DefaultP', default=[int, str]) # No error

So, the docstring of ParamSpec should show two examples with a list instead of a tuple as shown below:

type IntFuncDefault[**P = [int, str]] = Callable[P, int]

P = ParamSpec('P')
DefaultP = ParamSpec('DefaultP', default=[int, str])

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions