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

name-defined error lets Mypy forget TypedDict was wrapped in Unpack #17225

Open
tyralla opened this issue May 8, 2024 · 0 comments · May be fixed by #17226
Open

name-defined error lets Mypy forget TypedDict was wrapped in Unpack #17225

tyralla opened this issue May 8, 2024 · 0 comments · May be fixed by #17226
Labels
bug mypy got something wrong

Comments

@tyralla
Copy link
Contributor

tyralla commented May 8, 2024

from typing import overload, TypedDict, Unpack

class TD(TypedDict, total=False):
    x: float
    y: str

@overload
def f(*, x: float) -> None: ...
@overload
def f(*, y: str) -> None: ...
def f(**kwargs: Unpack[TD]) -> None:  # error: Overloaded function implementation does not accept all possible arguments of signature 1 [misc]
                                      # error: Overloaded function implementation does not accept all possible arguments of signature 1 [misc]
    y  # error: Name "y" is not defined

class A:
    def f(self, *, x: float) -> None: ...
class B(A):
    def f(self, **kwargs: Unpack[TD]) -> None:  # error: Argument 1 of "f" is incompatible with supertype "A"; supertype defines the argument type as "float"  [override]
        y  # type: ignore[name-defined]
reveal_type(B.f)  # note: Revealed type is "def (self: temp.B, **kwargs: TypedDict('temp.TD', {'x'?: builtins.float, 'y'?: builtins.str}))"
B().f(x=1.0)  # error: Argument "x" to "f" of "B" has incompatible type "float"; expected "TD"  [arg-type]
@tyralla tyralla added the bug mypy got something wrong label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
1 participant