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
Software as a ServiceUniversity of California, Berkeley via Coursera Software Testing
University of Utah via Udacity The Hardware/Software Interface
University of Washington via Coursera Software Debugging
Saarland University via Udacity Introduction to Systematic Program Design - Part 1
The University of British Columbia via Coursera