Skip to content

Commit fdac0c4

Browse files
committed
improve docs
1 parent 40aea35 commit fdac0c4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

docs/source/error_code_list2.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ values should indeed behave like `None`.
389389

390390
.. code-block:: python
391391
392-
# Use "mypy --enable-error-code optional-non-truthy ..."
392+
# mypy: enable-error-code="optional-non-truthy"
393393
394394
foo: None | int = 0
395395
# Error: "foo" has type "Optional[int]" where both None and some other values (of type: "int") may behave as false in boolean contexts. Consider being explicit about the behaviour for None vs other falsy values. [optional-non-truthy]
@@ -398,6 +398,15 @@ values should indeed behave like `None`.
398398
else:
399399
... # executes when foo is None or 0
400400
401+
For instance, in the case that `None` and `0` should behave differently:
402+
403+
.. code-block:: python
404+
405+
if foo is not None:
406+
... # executes when foo is any int, including 0
407+
else:
408+
... # executes when foo is None
409+
401410
.. _code-ignore-without-code:
402411

403412
Check that ``# type: ignore`` include an error code [ignore-without-code]

0 commit comments

Comments
 (0)