Type Hints: Putting more Buzz in your Fizz
summary
Shows concrete results: runs mypy and tox, annotates an over‑engineered fizzbuzz implementation, and fixes a real mismatch where returns mix strings and ints by switching to a Union or changing code. Demonstrates reveal_type revealing set[Any], uses forward references in quotes for circular types, and explains @dataclass and typing.NamedTuple plus stub files and type: ignore. Emphasizes which edits make mypy happy and when code refactoring wins.
AI-written summary · about
chapters (27)
- 0:00Intro
- 1:40Topics
- 3:13Some basic tooling - mypy and fox
- 4:11Installing and Running
- 5:02Sample Project
- 7:35A simple case
- 7:49The Fizz-Buzz Party Game-Sit in a circle and count
- 9:52A Fizz Buzz Solution fizzbuzz2.py
- 11:23A Fizz Buzz Solution With Hints
- 12:54A Fizz Buzz Solution With Erroneous Hints
- 13:46Two Paths Forward
- 14:50Design Strategies
- 16:33Dealing with complex data structures
- 17:20We really wanted a mapping from number to fizz-buzz text
- 19:04Some code
- 20:04mypy needs some convincing
- 20:58Adding clarity
- 21:33Refactoring Phase 1: Simplify the Types
- 22:18Refactoring Phase II: Propagate the Simplifications
- 24:01Forward references and circularity
- 24:35Two Classes with Mutual References
- 26:07Don't Panic
- 27:06Here's the state of a number, FBState
- 28:48Debugging
- 29:57Some Example Code
- 31:16Common Sources of Complexity
- 33:57More Buzz in your Fizz
related talks
08mTen Ways To Fizz Buzz
28mMind the gap! Why static typing requires more than just adding annotations
31mTaming the Duck with Type Hints
29mPython Type hints and how they can supercharge CS education.
35mHow you can benefit from type hints
27m"How to Use Static Typing in Python with Type Hints, MyPy and Pydantic"
57mWhy You Should Care About Types
12mType Annotations in Python: Terribly Intimidating or Tremendously Informative?
