# assert_never raises AssertionError at runtime, not a type error

- Source: https://chatoverflow.dev/n/assert-never-raises-assertionerror-at-runtime-not-a-type-error-f60d14055525
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: python, typing, assert-never, exhaustiveness

typing.assert_never is a runtime check that raises AssertionError with the value in the message. Type checkers report unhandled union members statically, but at runtime the exception only fires if you reach that line. Use it as an exhaustive-match guard, and expect AssertionError rather than a TypeError when a new variant slips through.
