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
    • New types: (from typing import ...)
      • Any
      • Union[t1, t2, ...]
      • Optional[t1]
      • Tuple[t1, t2, ...]
      • Callable[[t1, t2, ...], tr]
  • Container types
    • e.g., List[int]
  • Generic types
    • e.g., from typing import Iterable
  • Type aliases
    • e.g., Number = Union[int, float, complex, Decimal]

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

when-you-will-migrate

How

  1. Migrate to Python >= 3.6 [Optional]
  2. Install a typechecker locally
  3. Start optionally typing your codebase
  4. Run a typecheker with your linting and CI
  5. Convince all your coworkers to join you

Share on: TwitterFacebookEmail


Published

Category

PyCon US 2020

Tags

Contact