Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/guides/unreachable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ and is also present in ``typing_extensions`` starting at version 4.1.
However, it is also possible to define a similar function in your own
code, for example if you want to customize the runtime error message.

This use of match statements for comprehensive matching is common
enough that some typecheckers have direct support for checking all match
statements for exhaustiveness, regardless of whether or not they have an
``assert_never``-style function in their default arm. For instance, in pyright
this can be enabled by enabling the diagnostic code ``reportMatchNotExhaustive``
(on by default in strict mode), and in mypy it can be enabled by enabling
the error code ``exhaustive-match``.

You can also use ``assert_never()`` with a sequence of ``if`` statements:

.. code:: python
Expand Down