-
- Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
Description
Modules can implement protocols, so type(x) is not necessarily a type object if x has a protocol type.
from typing import Protocol class P(Protocol): def f(self) -> None: ... def f(p: P) -> None: reveal_type(type(p)) # type[P] (incorrect!)It's probably best to to generate an error if type is called on an object with a protocol type, as suggested by @hauntsaninja in #16890 (comment).
See #16890 for more context.
Hnasar