Skip to content

Instantly share code, notes, and snippets.

@johnsondnz
Created October 8, 2019 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnsondnz/2350ba547195f8a53559815d20bcdd4f to your computer and use it in GitHub Desktop.
Save johnsondnz/2350ba547195f8a53559815d20bcdd4f to your computer and use it in GitHub Desktop.
Small example on Python Typing
#!/usr/bin/env python3
def testing(a: int, b: int) -> int:
return a + b
print(testing(1,2))
from typing import Dict
from mypy_extensions import TypedDict
TestDict = TypedDict(
"TestDict",
{
"Key1": int,
"Key2": str
}
)
print(TestDict(
Key1=1,Key2=2
))
"""
/tmp ⌚ 10:16:53
$ mypy test.py
test.py:20: error: Incompatible types (expression has type "int", TypedDict item "Key2" has type "str")
Found 1 error in 1 file (checked 1 source file)
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment