Python, from Zero, for AILesson 67 of 89

Module 7 · Objects, generators and the shape a larger program takes

Running a type checker: the bugs it finds that tests do not

In this lesson

  • 9 min read
  • 8 reading sections
  • Knowledge check
  • Lesson 8 of 10 in this chapter

This chapter’s goalRestructure a growing script into classes and dataclasses with a swappable provider behind one interface, implement the dunder methods that let your objects work with for, len, in and with, write a decorator that retries or caches, run a type checker and act on its output, make the project installable as a command with pyproject.toml, and profile it to say from measurement rather than guesswork where the time goes.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmWatch1:40Not available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 10Free · no account needed
Lesson steps

What a test cannot see

A test runs one path through the code with one set of inputs. If the path where a function returns None was never exercised, the test does not know it exists. A type checker reads the code instead of running it and follows every path the annotations allow. That is a different kind of evidence, and it is cheap: no test data, no fixtures, one command.

Module 3 said hints are not enforced at runtime. This is where they get enforced.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Stuck on something?Ask Divya, your AI tutor

How to cite: Addaly (2026) ‘Running a type checker: the bugs it finds that tests do not’, in Python, from Zero, for AI. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/python-for-ai/running-a-type-checker (Accessed: 21 November 2026).