diff --git a/docs/guides/unreachable.rst b/docs/guides/unreachable.rst index d14e3cf0..7ad519b0 100644 --- a/docs/guides/unreachable.rst +++ b/docs/guides/unreachable.rst @@ -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