-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
Description
Currently a Type[Any] is considered to have the same attributes as Type[object]. However, actually it probably has many attributes that could be used, especially when the Any comes from a module without stubs. Consider the following example:
from typing import Type
from some_module import Candy, Lollipop # some_module has no stubs/annotations
class CandyFactory:
manufactured_candy: Type[Candy]
cf = CandyFactory()
cf.manufactured_candy = Lollipop
print(cf.manufactured_candy.sugar_level)Then running:
$ mypy --ignore-missing-imports candy.py
candy.py:11: error: Type[Any] has no attribute "sugar_level"
Which seems to go a bit against the idea of gradual typing and intention of Any.
One possible solution is to consider that Type[Any] == Any, I think this actually would not miss anything that could be catched now, while reducing false positives.