Static Typing in Python
summary
Defines static typing as optional since Python is dynamic, explains PEP 484 annotations (Python 3.5+), and demonstrates concrete fixes: annotating a parameter prevents the runtime bug AttributeError: 'dict' object has no attribute 'split'. Shows complex types (Union, Optional, Any, Sequence, generics) and recommends tools: mypy in CI plus alternatives pyre and pyright, and using monkeytype stubs to auto-generate annotations for legacy code while noting import-time overhead and added annotation work.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 8:00Why Type
- 10:39Test Cases
- 13:44Structure Typing
- 18:24Union Type
- 20:54Optional Type
- 24:19Generics
- 26:24Mypi
- 27:14Monkey Typing
- 29:29Pros Cons
- 31:54Questions
related talks
22mStatic Typing in Python
29mStatic Typing in Python
32mStatic Typing in Python
24mStatic type-checking is dead, long live static type-checking in Python!
23mGradual Typing in Python
27m"How to Use Static Typing in Python with Type Hints, MyPy and Pydantic"
28mMind the gap! Why static typing requires more than just adding annotations
16mTyping in Python: Bringing Clarity, Safety, and Speed to Your Code
