Skip to content

"Arguments for ParamSpec are missing" error #11358

@srittau

Description

@srittau

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:

_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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions