Bug Report, To Reproduce, & Actual Behaviour
This came about while writing a simple function to extract objects' fully-qualified names. See mypy Playground:
from typing import Protocol, Any class SupportsQualname(Protocol): __qualname__: str def f(C: SupportsQualname, /) -> str: return C.__qualname__ Class0: type = int Class1: type[int] = int Class2: type[Any] = int Class3: type[object] = int f(Class0) # OK f(Class1) # E: Argument 1 to "f" has incompatible type "type[int]"; expected "SupportsQualname" [arg-type] f(Class2) # E: Argument 1 to "f" has incompatible type "type[Any]"; expected "SupportsQualname" [arg-type] f(Class3) # E: Argument 1 to "f" has incompatible type "type[object]"; expected "SupportsQualname" [arg-type]
Expected Behavior
No errors
Your Environment
Yeah, __qualname__ exists for type since it's in typeshed, I suppose we don't use type as an instance as a fallback for TypeTypes and we should?
Oops, this is kind of a duplicate of #17567
Good catch! It's not obviously a duplicate but close enough (and definitely the same cause) so I'll just close this.
(also turns out I was wrong -- turns out TypeType doesn't have a fallback type!)
Activity
A5rocks commented on May 9, 2025
Yeah, __qualname__ exists for type since it's in typeshed, I suppose we don't use type as an instance as a fallback for TypeTypes and we should?
bzoracler commented on May 9, 2025
Oops, this is kind of a duplicate of #17567
A5rocks commented on May 9, 2025
Good catch! It's not obviously a duplicate but close enough (and definitely the same cause) so I'll just close this.
(also turns out I was wrong -- turns out TypeType doesn't have a fallback type!)