Skip to content

Commit 7e8cb1c

Browse files
committed
add option --strict-equality-for-none
1 parent e37d706 commit 7e8cb1c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

docs/source/command_line.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,22 @@ of the above sections.
728728
if text != b'other bytes': # Error: non-overlapping equality check!
729729
...
730730
731-
assert text is not None # OK, check against None is allowed as a special case.
731+
assert text is not None # OK, check against None is allowed for historical reasons.
732732
733733
734+
.. option:: --strict-equality-for-none
735+
736+
This flag extends :option:`--strict-equality <mypy --strict-equality>` for checks
737+
against ``None``:
738+
739+
.. code-block:: python
740+
741+
text: str
742+
assert text is not None # Error: non-overlapping identity check!
743+
744+
Note that :option:`--strict-equality-for-none <mypy --strict-equality-for-none>`
745+
only works in combination with :option:`--strict-equality <mypy --strict-equality>`.
746+
734747
.. option:: --strict-bytes
735748

736749
By default, mypy treats ``bytearray`` and ``memoryview`` as subtypes of ``bytes`` which

0 commit comments

Comments
 (0)