With python 3.5.1. and a current installation of mypy using git, mypy flags error 1 & 2, but it does not report 3
What am I doing wrong, or is this a bug, or is this a known problem?
import typing
def test_ordered_dict(od: typing.Dict[str,int]) -> typing.Dict[str,int]:
return 1 #type error 1
a = test_ordered_dict(1) #type error 2
def test_me():
a = test_ordered_dict(1) # type error 3 is not reported
My understanding from the docs is that mypy will only check a thing (module, function, whatever) if it's indicated to it that it should check it (by importing typing at module level or by annotating a function).
So 1 is checked because it's in a function which is typed, 2 is checked as the import typing indicates that your module is typed and it's at module scope but 3 is in the scope of an untyped function so it's ignored.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With