Type Hints - Putting More Buzz in Your Fizz
Offered By: PyCon US via YouTube
Course Description
Overview
Explore type hints in Python and their importance in the ecosystem through this 37-minute PyCon US sponsor workshop. Learn how to implement type hints incrementally, use tools like mypy for checking, and incorporate them into CI/CD pipelines. Dive into hands-on examples, starting with simple cases and progressing to complex data structures, circular type references, and debugging techniques. Discover easy ways to add type hints to class definitions using typing.NamedTuple and @dataclass decorator. Gain insights on writing stubs for libraries without type hints and when to use the type: ignore comment. Apply these concepts to enhance the classic Fizz-Buzz game, refactoring code for clarity and simplicity while addressing common sources of complexity in type hinting.
Syllabus
Intro
Topics
Some basic tooling - mypy and fox
Installing and Running
Sample Project
A simple case
The Fizz-Buzz Party Game-Sit in a circle and count
A Fizz Buzz Solution fizzbuzz2.py
A Fizz Buzz Solution With Hints
A Fizz Buzz Solution With Erroneous Hints
Two Paths Forward
Design Strategies
Dealing with complex data structures
We really wanted a mapping from number to fizz-buzz text
Some code
mypy needs some convincing
Adding clarity
Refactoring Phase 1: Simplify the Types
Refactoring Phase II: Propagate the Simplifications
Forward references and circularity
Two Classes with Mutual References
Don't Panic
Here's the state of a number, FBState
Debugging
Some Example Code
Common Sources of Complexity
More Buzz in your Fizz
Taught by
PyCon US
Related Courses
Intro to Computer ScienceUniversity of Virginia via Udacity Design of Computer Programs
Stanford University via Udacity Analytic Combinatorics, Part I
Princeton University via Coursera Algorithms, Part I
Princeton University via Coursera Algorithms, Part II
Princeton University via Coursera