Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParamSpec: mypy is happy for args to be annotated with P.kwargs and kwargs to be annotated with P.args #13460

Closed
AlexWaygood opened this issue Aug 20, 2022 · 0 comments · Fixed by #13468
Labels
bug mypy got something wrong topic-paramspec PEP 612, ParamSpec, Concatenate

Comments

@AlexWaygood
Copy link
Member

Bug Report

Mypy has no issues with this snippet of code. It probably should:

from typing import Callable
from typing_extensions import ParamSpec

P = ParamSpec("P")

def func(callback: Callable[P, str]) -> Callable[P, str]:
    def inner(*args: P.kwargs, **kwargs: P.args) -> str:
        return 'baz'
    return inner

This bug was accidentally discovered in #13459.

To Reproduce

https://mypy-play.net/?mypy=latest&python=3.10&gist=87f5f5277409f0fd77675e8dcc6a11fc

Expected Behavior

Mypy should emit two errors for this snippet:

  1. *args have been annotated with P.kwargs instead of P.args
  2. **kwargs have been annotated with P.args instead of P.kwargs

Actual Behavior

No error is emitted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-paramspec PEP 612, ParamSpec, Concatenate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant