Skip to content

Instantly share code, notes, and snippets.

@chintanop
Created September 23, 2015 16:10
Show Gist options
  • Save chintanop/9ce762314538b1e6ee67 to your computer and use it in GitHub Desktop.
Save chintanop/9ce762314538b1e6ee67 to your computer and use it in GitHub Desktop.
Test MyPy
class Test1:
def create(self, a:int, b:str) -> None:
print("hello")
class Test2:
def create(self):
""" No error or warning generated even if first argument is a string here"""
a = "abc" # should've complained here!
b = "def"
Test1().create(a, b)
if __name__ == "__main__":
a = 5 # works correcty
""" If a is changed to "abc", it complains CORRECTLY:
Argument 1 to "create" of "Test1" has incompatible type "str"; expected "int"
"""
b = "def"
Test1().create(a,b)
Test2().create()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment