Skip to content

Kwargs after ParamSpec.args should be tolerated #19506

@kdkavanagh

Description

@kdkavanagh

Bug Report
I believe mypy's handling of ParamSpecs is slightly too restrictive. Currently, it validates that there are no args or kwargs after a ParamSpec.args argument other than **kwargs. I believe it's tolerable to have kwargs follow a ParamSpec.args

Related to #18278

To Reproduce

def f5(f: Callable[P, int], *args: P.args, extra_regular_arg: int, **kwargs: P.kwargs) -> int: ...  # E: Arguments not allowed after ParamSpec.args

def f6(f: Callable[P, int], *args: P.args, extra_kwarg: int = 123, **kwargs: P.kwargs) -> int: ...  # E: Arguments not allowed after ParamSpec.args

Expected Behavior
The first function above should continue to fail, while the second function should not throw an error

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions