File: inline_config.rst

package info (click to toggle)
mypy 1.17.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 21,048 kB
  • sloc: python: 108,159; cpp: 11,380; ansic: 7,255; makefile: 247; sh: 27
file content (43 lines) | stat: -rw-r--r-- 1,164 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
.. _inline-config:

Inline configuration
====================

Mypy supports setting per-file configuration options inside files themselves
using ``# mypy:`` comments. For example:

.. code-block:: python

  # mypy: disallow-any-generics

Inline configuration comments take precedence over all other
configuration mechanisms.

Configuration comment format
****************************

Flags correspond to :ref:`config file flags <config-file>` but allow
hyphens to be substituted for underscores.

Values are specified using ``=``, but ``= True`` may be omitted:

.. code-block:: python

  # mypy: disallow-any-generics
  # mypy: always-true=FOO

Multiple flags can be separated by commas or placed on separate
lines. To include a comma as part of an option's value, place the
value inside quotes:

.. code-block:: python

  # mypy: disallow-untyped-defs, always-false="FOO,BAR"

Like in the configuration file, options that take a boolean value may be
inverted by adding ``no-`` to their name or by (when applicable)
swapping their prefix from ``disallow`` to ``allow`` (and vice versa):

.. code-block:: python

  # mypy: allow-untyped-defs, no-strict-optional