-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
Description
Bug Report
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 heresource: https://gist.github.com/mypy-play/843cafceeef590efc6d3705b44c29c19
playground: https://mypy-play.net/?mypy=latest&python=3.11&gist=843cafceeef590efc6d3705b44c29c19
Expected Behavior
reveal_type(Meta.__dict__) returns types.MappingProxyType[builtins.str, Any]
No errors reported by mypy for this file.
Actual Behavior
mypy_test.py:6: note: Revealed type is "def (self: builtins.type) -> types.MappingProxyType[builtins.str, Any]"
mypy_test.py:7: error: Value of type "Callable[[type], MappingProxyType[str, Any]]" is not indexable [index]
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.7.0
- Mypy command-line flags:
--check-untyped-defs - Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.10