8000 "Overloaded function implementation does not accept all possible arguments" · Issue #11391 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content
8000

"Overloaded function implementation does not accept all possible arguments" #11391

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

Open
9999years opened this issue Oct 26, 2021 · 0 comments
Open
Labels
bug mypy got something wrong topic-overloads

Comments

@9999years
Copy link
9999years commented Oct 26, 2021

False positive; mypy doesn't believe that Foo[T] is a subtype of T.

from typing import Union, Generic, TypeVar, overload

T = TypeVar("T")

class Foo(Generic[T]):
    pass

@overload
def expect(pattern: Foo[T]) -> None: ...

@overload
def expect(pattern: T) -> None: ...

def expect(pattern: Union[Foo[T], T]) -> None: return None
$ mypy xxx.py
xxx.py:14: error: Overloaded function implementation does not accept all possible arguments of signature 1

Note that the second overload referencing the type variable used in the first overload is necessary; if pattern: int is used instead of pattern: T in the second overload, mypy type-checks the file correctly.

Environment

  • Mypy version used: 0.910
  • Python version used: 3.10 and 3.7
  • Operating system and version: Fedora 34

Related issues

I think that #10390 fixes this issue, but I'm not sure.

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-overloads
Projects
None yet
Development

No branches or pull requests

2 participants
0