-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
Initially lodged as python/mypy#16501
Given a metaclass called Meta, mypy considers the Meta.dict attribute to have type def (self: builtins.type) -> types.MappingProxyType[builtins.str, Any] when the actual type is types.MappingProxyType[builtins.str, Any].
To Reproduce
Run mypy on this file.
class Meta(type):
def __call__(cls, *args, **kw):
return super().__call__(*args, **kw)
reveal_type(Meta.__dict__)
call = Meta.__dict__['__call__'] # mypy raises error herehttps://mypy-play.net/?mypy=latest&python=3.11&gist=843cafceeef590efc6d3705b44c29c19
Expected Behavior
reveal_type(Meta.__dict__) returns types.MappingProxyType[builtins.str, Any]
Actual Behavior
mypy_test.py:6: note: Revealed type is "def (self: builtins.type) -> types.MappingProxyType[builtins.str, Any]"
This is likely due to builtins.pyi defining __dict__ as a property.
class type:
...
@property
def __dict__(self) -> types.MappingProxyType[str, Any]: ... # type: ignore[override]Metadata
Metadata
Assignees
Labels
No labels