microsoft / microsoft/pyright

"Arguments for ParamSpec are missing" error

Open
#11,358 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
15.6k
Forks
1.8k
Avg merge
12h 13m
Merged PRs (30d)
52

Description

**Describe the bug**

Please have a look at python/typeshed#15597. In this PR, I try to change `operator.methodcaller` to use a `ParamSpec` with defaults:

```python
_P = ParamSpec("_P", default=...)
_R = TypeVar("_R", default=Any)

@final
class methodcaller(Generic[_P, _R]):
def __new__(cls, name: str, /, *args: _P.args, **kwargs: _P.kwargs) -> methodcaller[_P, Any]: ...
def __call__(self, obj: Any) -> _R: ...
```

Unfortunately, the following test cases then fail:

```python
m1 = methodcaller("foo") # Arguments for ParamSpec "_P@methodcaller" are missing (reportCallIssue)
assert_type(m1, methodcaller[[], Any]) # "assert_type" mismatch: expected "methodcaller[(), Any]" but received "methodcaller[..., Any]"
m2 = methodcaller("foo", 42, bar="") # Arguments for ParamSpec "_P@methodcaller" are missing (reportCallIssue)
```

I'm unsure what there problem here seems to be.

From the CI environment:

pyright 1.1.408, node v24.14.0, pyright-action 3.0.2

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the supplied `methodcaller` examples using the reported pyright 1.1.408 environment, then trace how the ParamSpec defaults and `assert_type` results are inferred. Use python/typeshed#15597 as the expected usage context. Done means the calls no longer report missing ParamSpec arguments and the asserted types match the inferred types.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.