mypy icon indicating copy to clipboard operation
mypy copied to clipboard

(🐞) `Protocol`s that narrow to modules become `Any`

Open KotlinIsland opened this issue 1 year ago • 0 comments

from typing import Protocol

import test2  # def foo() -> None: ...

class P(Protocol):
    def foo(self) -> None: ...

a: P = test2
reveal_type(a.foo())  # None
a = test2
reveal_type(a.foo())  # Any

KotlinIsland avatar Feb 13 '24 13:02 KotlinIsland