from werkzeug.datastructures import TypeConversionDict
d = TypeConversionDict()
def parse_int(value: str) -> int:
return int(value)
d.get("foo", type=int)
d.get("foo", type=parse_int)
foo.py:13:1: error: No overload variant of "get" of "TypeConversionDict" matches argument types "str", "Callable[[str], int]" [call-overload]
d.get("foo", type=parse_int)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
foo.py:13:1: note: Possible overload variants:
foo.py:13:1: note: def get(self, key: Any) -> Any | None
foo.py:13:1: note: def get(self, key: Any, default: Any) -> Any
foo.py:13:1: note: def [T] get(self, key: Any, default: T) -> Any | T
foo.py:13:1: note: def [T] get(self, key: str, type: type[T]) -> T | None
foo.py:13:1: note: def [T] get(self, key: str, default: T, type: type[T]) -> T
Given the following code
mypy complains with
It seems like that the type hint for
typeis too limited and should also include callables as the docstring saysEnvironment: