Acknowledgments
Introduction
- Tools Needed
- Audience
- About the Author
- Conventions
- Book Source Code
- Reader Feedback
- Errata
Chapter 1 - An Intro to Typing
- What are types?
- Dynamic vs Static types
- Strong vs Weak Types
- Type hinting / annotations / checking
- Uses for type hints
- Pros of Type Hinting
- Cons of Typing Hinting
- When to Use Type Hints
- Wrapping Up
Chapter 2 - Basic Type Hinting
- Detecting Types
- Type Hinting Variables
- Type Hinting Collections
- Type Hinting Functions
- Handling Multiple Types
- Optional Types
- Wrapping Up
Chapter 3 - Aliases and Custom Types
- Creating Type Aliases
- Creating Generics
- Creating a New Type
- Annotating Callable and Awaitable Objects
- Using the
AnyType - Wrapping Up
Chapter 4 - Adding Type Hints to Complex Dictionaries
- Type Hinting a Regular Dictionary
- Creating a TypedDict
- Creating a TypedDict with Keys that Have Spaces
- Wrapping Up
Chapter 5 - Type Hinting Generators, Decorators and Iterators
- Type Hinting Generators
- Type Hinting Iterators / Iterables
- Type Hinting Async Generators and Iterators
- Type Hinting Decorators
- Wrapping Up
Chapter 6 - Type Hinting a NamedTuple
- Defining the
namedtuple - Type Hinting the NamedTuple
- Wrapping Up
Chapter 7 - Working with Special Types
typing.Anytyping.AnyStrtyping.LiteralStringtyping.Never/typing.NoReturntyping.Selftyping.TypeAlias- Wrapping Up
Chapter 8 - The Mypy Type Checker
- Installing mypy
- Running mypy
- Using the mypy Command Line
- Configuring mypy
- Ignoring Errors
- Excluding Files / Folders
- Speeding Up mypy
- Wrapping Up
Chapter 9 - The ty Type Checker
- Installing ty
- Running ty
- Configuring ty
- Ignoring Errors
- Excluding Files or Folders
- Wrapping Up
Chapter 10 - The pyrefly Type Checker
- Installing Pyrefly
- Running Pyrefly
- Configuring Pyrefly
- Ignoring Errors
- Excluding Files or Folders
- Automatically Adding Type Hints
- Measuring Type Coverage
- Wrapping Up
Chapter 11 - Using Type Checkers with pre-commit
- Installing and Initializing pre-commit
- Using mypy with pre-commit
- Using ty with pre-commit
- Wrapping Up
Chapter 12 - GitHub Actions
- A Brief Overview of GitHub Actions
- Creating a mypy GitHub Action
- Creating a ty GitHub Action
- Wrapping Up
