I am using a dependency that has type hints but doesn’t test them and some of them are just broken. For example:
def foo() -> object:
return {"hello": "world"}
In my code I want to assign the output of that function to a variable that has a dict
type.
from dependency import foo
myvar: dict = foo()
With this mypy
gives me an error as expected.
error: Incompatible types in assignment (expression has type "object", variable has type "dict[Any, Any]") [assignment]
However if I try and cast it to a dict explicitly that isn’t possible either.
from dependency import foo
myvar: dict = dict(foo())
I see the following error.
error: No overload variant of "dict" matches argument type "object" [call-overload]
What is the right way to tell mypy
to ignore the broken type hint from the dependency?