# Exhaustiveness Checking with Mypy

DevFeed: [Exhaustiveness Checking with Mypy](<https://devfeed.tech/articles/exhaustiveness-checking-with-mypy-33932.md>)

Original publisher: [Read original article](<https://hakibenita.com/python-mypy-exhaustive-checking>)

Author: Haki Benita

Published: 2020-12-07T22:00:00Z

Content type: tutorial

Language: en

Sources: [Haki Benita](<https://devfeed.tech/sources/haki-benita.md>)

Topics: [Python](<https://devfeed.tech/topics/python.md>), [enum](<https://devfeed.tech/topics/enum.md>), [ci](<https://devfeed.tech/topics/ci.md>), [Exception](<https://devfeed.tech/topics/exception.md>), [Visual Studio Code](<https://devfeed.tech/topics/visual-studio-code.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [articles](<https://devfeed.tech/tags/articles.md>), [ci](<https://devfeed.tech/tags/ci.md>), [django](<https://devfeed.tech/tags/django.md>), [enum](<https://devfeed.tech/tags/enum.md>), [exception](<https://devfeed.tech/tags/exception.md>), [python](<https://devfeed.tech/tags/python.md>), [runtime-errors](<https://devfeed.tech/tags/runtime-errors.md>), [vscode](<https://devfeed.tech/tags/vscode.md>)

## AI overview

This tutorial explains how to use mypy, an optional static type checker for Python, to detect unhandled values in enumerations before runtime. It presents a helper function that enables exhaustiveness checking, shows the resulting warning, and describes integrating mypy into CI.

## Source excerpt

What if mypy could warn you about possible problems at "compile time"? In this article I share a little trick to get mypy to fail when a value in an enumeration type is left unhandled.