-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Bug Report
type-abstract is falsely missing when initializing a dictionary.
To Reproduce
"""False-negative `type-abstract`."""
from abc import abstractmethod
class Class:
@abstractmethod
def method(self) -> None:
pass
my_list: list[type[Class]] = []
my_list.append(Class) # type-abstract
my_list_init: list[type[Class]] = [Class] # type-abstract
my_dict: dict[int, type[Class]] = {}
my_dict[0] = Class # type-abstract
my_dict_init: dict[int, type[Class]] = {0: Class} # *no* type-abstracthttps://mypy-play.net/?mypy=latest&python=3.11&gist=2f58d30cce7e6ddadfc2b0f28ef68395
Expected Behavior
main.py:10: error: Only concrete class can be given where "Type[Class]" is expected [type-abstract]
main.py:12: error: Only concrete class can be given where "Type[Class]" is expected [type-abstract]
main.py:15: error: Only concrete class can be given where "Type[Class]" is expected [type-abstract]
main.py:17: error: Only concrete class can be given where "Type[Class]" is expected [type-abstract]
Found 4 errors in 1 file (checked 1 source file)
Actual Behavior
main.py:10: error: Only concrete class can be given where "Type[Class]" is expected [type-abstract]
main.py:12: error: Only concrete class can be given where "Type[Class]" is expected [type-abstract]
main.py:15: error: Only concrete class can be given where "Type[Class]" is expected [type-abstract]
Found 3 errors in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.3.0
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.11.3