-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
Going through Mypy's tests, I realized that some tests are passing that shouldn't. This involves for example:
testConditionalFunctionDefinitionUsingDecorator3
(there's an error in the test that the test author probably didn't notice: Positional only args of a callable are never assignable to a normal function with positional-or-keyword params; typically an error in Mypy would look like this:Incompatible redefinition (redefinition with type "Callable[[int], None]", original type "Callable[[Arg(int, 'x')], None]")
)testConditionalFunctionDefinitionUsingDecorator4
(there's even a TODO in there that complains about this not being done)testNewAnalyzerConditionalDecoratedFunc
To Reproduce
from typing import Callable
def dec(f) -> Callable[[int], None]: raise NotImplementedError
if int():
def f(x: str): pass
else:
@dec
def f() -> None: pass
https://mypy-play.net/?mypy=latest&python=3.12&gist=18b131da809d740eced20dd7652ea213
Expected Behavior
It would be nice if Mypy complained here (like in AFAIK all other conditional definitions).
I'm happy to assist if somebody wants to fix this.
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong