I have a class that is essentially a wrapper around a dictionary:
class Wrapper(dict):
...
def __getitem__(self, item: Hashable) -> Any:
return self.wrapped[item]
When checking the annotations with mypy
, it yields an Explicit "Any" is not allowed
when checking this code. My guess is that this stems from the concept that Any
is the ancestor and successor of all other types. How should I annotate such function where I want to allow anything to be returned?
This happens when the disallow_any_explicit
is set to True
for that module in the configuration file. Just remove that option for the default False
.