@@ -5,8 +5,8 @@ Error codes for optional checks
5
5
6
6
This section documents various errors codes that mypy generates only
7
7
if you enable certain options. See :ref: `error-codes ` for general
8
- documentation about error codes. :ref: ` error-code-list ` documents
9
- error codes that are enabled by default.
8
+ documentation about error codes and their configuration.
9
+ :ref: ` error-code-list ` documents error codes that are enabled by default.
10
10
11
11
.. note ::
12
12
@@ -241,7 +241,7 @@ mypy generates an error if it thinks that an expression is redundant.
241
241
242
242
.. code-block :: python
243
243
244
- # Use " mypy -- enable-error-code redundant-expr ... "
244
+ # mypy: enable-error-code=" redundant-expr"
245
245
246
246
def example (x : int ) -> None :
247
247
# Error: Left operand of "and" is always true [redundant-expr]
@@ -268,7 +268,7 @@ example:
268
268
269
269
.. code-block :: python
270
270
271
- # Use " mypy -- enable-error-code possibly-undefined ... "
271
+ # mypy: enable-error-code=" possibly-undefined"
272
272
273
273
from typing import Iterable
274
274
@@ -297,7 +297,7 @@ Using an iterable value in a boolean context has a separate error code
297
297
298
298
.. code-block :: python
299
299
300
- # Use " mypy -- enable-error-code truthy-bool ... "
300
+ # mypy: enable-error-code=" truthy-bool"
301
301
302
302
class Foo :
303
303
pass
@@ -347,7 +347,7 @@ Example:
347
347
348
348
.. code-block :: python
349
349
350
- # Use " mypy -- enable-error-code ignore-without-code ... "
350
+ # mypy: enable-error-code=" ignore-without-code"
351
351
352
352
class Foo :
353
353
def __init__ (self , name : str ) -> None :
@@ -378,7 +378,7 @@ Example:
378
378
379
379
.. code-block :: python
380
380
381
- # Use " mypy -- enable-error-code unused-awaitable ... "
381
+ # mypy: enable-error-code=" unused-awaitable"
382
382
383
383
import asyncio
384
384
@@ -462,7 +462,7 @@ Example:
462
462
463
463
.. code-block :: python
464
464
465
- # Use " mypy -- enable-error-code explicit-override ... "
465
+ # mypy: enable-error-code=" explicit-override"
466
466
467
467
from typing import override
468
468
@@ -536,7 +536,7 @@ Now users can actually import ``reveal_type`` to make the runtime code safe.
536
536
537
537
.. code-block :: python
538
538
539
- # Use " mypy -- enable-error-code unimported-reveal"
539
+ # mypy: enable-error-code=" unimported-reveal"
540
540
541
541
x = 1
542
542
reveal_type(x) # Note: Revealed type is "builtins.int" \
@@ -546,7 +546,7 @@ Correct usage:
546
546
547
547
.. code-block :: python
548
548
549
- # Use " mypy -- enable-error-code unimported-reveal"
549
+ # mypy: enable-error-code=" unimported-reveal"
550
550
from typing import reveal_type # or `typing_extensions`
551
551
552
552
x = 1
0 commit comments