2. What Are Python Type Hints?
● New in 3.5 (provisional)
● PEP484
● Optional (not enforced at runtime)
○ Linter use recommended instead
● Function annotations
● Type Aliases, NewType, Callable, Generics ...
PEP=Python Enhancement Proposal
PEP484 primary focus is function annotation
See typing module for others… - NewType is for distinct types, Generics is for statically inferring types in containers
PyCharm (community ed. used here) does linting
mypy: new, experimental static type checker
PyCharm community edition
danger of truncation errors...
PyCharm community edition
PyCharm community edition
if type not specified, assumes Any
may prevent bugs from making assumptions about expected input and output types
Adds complexity to Python syntax. Good IDE like PyCharm provides prompts