microsoft / microsoft/pyright

Whether strict mode or not, setting an empty tuple to the generic type alias type argument of `ParamSpec` base gets no error

Open
#11,225 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
15.6k
Forks
1.8k
Avg merge
12h 13m
Merged PRs (30d)
52

Description

*Memo:

  • pyright test.py
  • pyright 1.1.407
  • Python 3.14.0
  • Windows 11

Whether strict mode or not, setting an empty tuple to the generic class and function type argument of ParamSpec base gets the errors, which is proper I think as shown below:

class Cls[**P]: ...

       # ↓↓
cls: Cls[()] # Error

error: Too few type arguments provided for "Cls"; expected 1 but received 0

def func[**P]() -> None: ...

      # ↓↓
v: func[()] # Error

error: Expected class but received "() -> None"

But whether strict mode or not, setting an empty tuple to the generic type alias type argument of ParamSpec base gets no error, which is improper I think as shown below:

from typing import Callable

type TA[**P] = Callable[P, None]

    # ↓↓
v: TA[()] # No error

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the report with test.py and pyright 1.1.407, comparing the diagnostics for Cls[()], func[()] and the ParamSpec-based alias TA[()]. Trace the generic type-alias handling involved in the last case. Done means TA[()] reports the invalid empty type argument consistently in strict and non-strict modes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.