Skip to content

Commit 04a2c19

Browse files
Update unreachable.rst: mention match exhaustiveness codes from checkers type … (#2062)
1 parent c141cdf commit 04a2c19

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/guides/unreachable.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ and is also present in ``typing_extensions`` starting at version 4.1.
8686
However, it is also possible to define a similar function in your own
8787
code, for example if you want to customize the runtime error message.
8888

89+
This use of match statements for comprehensive matching is common
90+
enough that some typecheckers have direct support for checking all match
91+
statements for exhaustiveness, regardless of whether or not they have an
92+
``assert_never``-style function in their default arm. For instance, in pyright
93+
this can be enabled by enabling the diagnostic code ``reportMatchNotExhaustive``
94+
(on by default in strict mode), and in mypy it can be enabled by enabling
95+
the error code ``exhaustive-match``.
96+
8997
You can also use ``assert_never()`` with a sequence of ``if`` statements:
9098

9199
.. code:: python

0 commit comments

Comments
 (0)