~/talk

Typing your Python code like a ninja!

Talkat PyCon Italia 2025 · 2025-05-28..05-31· [typescript]
slides:none on file

Covers concrete typing techniques and shows them working: uses overload with a single implementation to give precise return types (example: get_user with strict=True → User, strict=False → Optional[User]), applies generics and bounded TypeVar so double(x) preserves type but forbids Decimal, demonstrates TypeGuard narrows types so is_user(obj) lets the checker treat obj as User, uses TypedDict for kwargs to catch missing fields at type check time, and adds override decorator and typing.Self to prevent signature regressions; examples compile with mypy/pyright and sometimes need tweaks for real frameworks.

AI-written summary · about

  1. 0:00Introduction
  2. 1:09Basic type examples
  3. 2:36Overload for flexible types
  4. 4:23Generics in Python
  5. 6:30Generic classes
  6. 7:14Generic callables
  7. 9:02Type narrowing issues
  8. 10:05Type guard vs type is
  9. 12:09TypeDict for kwargs
  10. 14:14Overrides in inheritance
  11. 16:42Typing self in builders
  12. 19:36Final ninja example
  13. 20:17Q&A session
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.