5min talk on Python Type Hints. Presented at newhaven.io
Type Hints
View Slide
José Padilla
WorkTraining
WorkOpen Source
PEP 3107
PEP 484
no type checkinghappens atruntime
static analysisrefactoringruntime type checkingcode generation
Common built-in types
Generics
mypy
static type checker
$ pip install mypy
$ python app.py
$ python app.pyf1Traceback (most recent call last):File "app.py", line 12, in print(first(1)) # TypeErrorFile "app.py", line 7, in firstreturn seq[0]TypeError: 'int' object is not subscriptable
$ mypy app.py
$ mypy app.pymain.py:12: error: Argument 1 to "first" hasincompatible type "int"; expected"Sequence[]"
mypy-lang.org
Python will remain adynamically typedlanguage
Thanks!jpadilla.comtwitter.com/@jpadilla_github.com/jpadilla