Speaker
Dustin Ingram
Material
Note
PEPs
Types
- Gradual typing
- not do it all at once
- Special type consturcts
- Existing types
- e.g.,
int
,float
,str
,NoneType
- e.g.,
- New types: (
from typing import ...
)Any
Union[t1, t2, ...]
Optional[t1]
Tuple[t1, t2, ...]
Callable[[t1, t2, ...], tr]
- Existing types
- Container types
- e.g.,
List[int]
- e.g.,
- Generic types
- e.g.,
from typing import Iterable
- e.g.,
- Type aliases
- e.g.,
Number = Union[int, float, complex, Decimal]
- e.g.,
When you shouldn't use static typing
- basically never
- not a replacement for unit tests
When you should use static typing
- basically always
- especially
- if your project is for public consumption
- before migrating or refactoring
How
- Migrate to Python >= 3.6 [Optional]
- Install a typechecker locally
- Start optionally typing your codebase
- Run a typecheker with your linting and CI
- Convince all your coworkers to join you