Config file format
The configuration file format is the usualini file format. It should containsection names in square brackets and flag settings of the formNAME = VALUE. Comments start with #
characters.
A section named
[mypy]
must be present. This specifiesthe global flags. Thesetup.cfg
file is an exception to this.Additional sections named
[mypy-PATTERN1,PATTERN2,…]
may bepresent, wherePATTERN1
,PATTERN2
, etc., are comma-separatedpatterns of fully-qualified module names, with some components optionallyreplaced by the ‘’ character (e.g.foo.bar
,foo.bar.
,foo.*.baz
).These sections specify additional flags that only apply to _modules_whose name matches at least one of the patterns.
A pattern of the form qualified_module_name
matches only the named module,while dotted_module_name.
matches dotted_module_name
and anysubmodules (so foo.bar.
would match all of foo.bar
,foo.bar.baz
, and foo.bar.baz.quux
).
Patterns may also be “unstructured” wildcards, in which stars mayappear in the middle of a name (e.gsite..migrations.
). Stars match zero or more modulecomponents (so site..migrations.
can match site.migrations
).
- When options conflict, the precedence order for configuration is:
- Inline configuration in the source file
- Sections with concrete module names (
foo.bar
) - Sections with “unstructured” wildcard patterns (
foo.*.baz
),with sections later in the configuration file overridingsections earlier. - Sections with “well-structured” wildcard patterns(
foo.bar.*
), with more specific overriding more general. - Command line options.
- Top-level configuration file options.
The difference in precedence order between “structured” patterns (byspecificity) and “unstructured” patterns (by order in the file) isunfortunate, and is subject to change in future versions.
Note
The warn_unused_configs
flag may be useful to debug misspelledsection names.
Note
Configuration flags are liable to change between releases.