module documentation
(source)

Undocumented

Class ​Config​TOMLValue​Error Undocumented
Function check​_follow​_imports Undocumented
Function convert​_to​_boolean Return a boolean value translating from other types if necessary.
Function destructure​_overrides Take the new [[tool.mypy.overrides]] section array in the pyproject.toml file, and convert it back to a flatter structure that the existing config_parser can handle.
Function expand​_path Expand the user home directory and any environment variables contained within the provided path.
Function get​_config​_module​_names Undocumented
Function get​_prefix Undocumented
Function is​_toml Undocumented
Function mypy​_comments​_to​_config​_map Rewrite the mypy comment syntax into ini file syntax.
Function parse​_config​_file Parse a config file into an Options object.
Function parse​_mypy​_comments Parse a collection of inline mypy: configuration comments.
Function parse​_section Parse one section of a config file.
Function parse​_version Undocumented
Function split​_and​_match​_files Take a string representing a list of files/directories (with support for globbing through the glob library).
Function split​_and​_match​_files​_list Take a list of files/directories (with support for globbing through the glob library).
Function split​_directive Split s on commas, except during quoted sections.
Function try​_split Split and trim a str or list of str into a list of str
Constant ini​_config​_types Undocumented
Constant toml​_config​_types Undocumented
Constant _CONFIG​_VALUE​_TYPES Undocumented
Constant _INI​_PARSER​_CALLABLE Undocumented
def check_follow_imports(choice): (source)

Undocumented

Parameters
choice:strUndocumented
Returns
strUndocumented
def convert_to_boolean(value): (source)
Return a boolean value translating from other types if necessary.
Parameters
value:Optional[Any]Undocumented
Returns
boolUndocumented
def destructure_overrides(toml_data): (source)

Take the new [[tool.mypy.overrides]] section array in the pyproject.toml file, and convert it back to a flatter structure that the existing config_parser can handle.

E.g. the following pyproject.toml file:

[[tool.mypy.overrides]] module = [

"a.b", "b.*"

] disallow_untyped_defs = true

[[tool.mypy.overrides]] module = 'c' disallow_untyped_defs = false

Would map to the following config dict that it would have gotten from parsing an equivalent ini file:

{
"mypy-a.b": {
disallow_untyped_defs = true,

}, "mypy-b.*": {

disallow_untyped_defs = true,

}, "mypy-c": {

disallow_untyped_defs: false,

},

}

Parameters
toml​_data:Dict[str, Any]Undocumented
Returns
Dict[str, Any]Undocumented
def expand_path(path): (source)
Expand the user home directory and any environment variables contained within the provided path.
Parameters
path:strUndocumented
Returns
strUndocumented
def get_config_module_names(filename, modules): (source)

Undocumented

Parameters
filename:Optional[str]Undocumented
modules:List[str]Undocumented
Returns
strUndocumented
def get_prefix(file_read, name): (source)

Undocumented

Parameters
file​_read:strUndocumented
name:strUndocumented
Returns
strUndocumented
def is_toml(filename): (source)

Undocumented

Parameters
filename:strUndocumented
Returns
boolUndocumented
def mypy_comments_to_config_map(line, template): (source)

Rewrite the mypy comment syntax into ini file syntax.

Returns

Parameters
line:strUndocumented
template:OptionsUndocumented
Returns
Tuple[Dict[str, str], List[str]]Undocumented
def parse_config_file(options, set_strict_flags, filename, stdout=None, stderr=None): (source)

Parse a config file into an Options object.

Errors are written to stderr but are not fatal.

If filename is None, fall back to default config files.

Parameters
options:OptionsUndocumented
set​_strict​_flags:Callable[[], None]Undocumented
filename:Optional[str]Undocumented
stdout:Optional[TextIO]Undocumented
stderr:Optional[TextIO]Undocumented
def parse_mypy_comments(args, template): (source)

Parse a collection of inline mypy: configuration comments.

Returns a dictionary of options to be applied and a list of error messages generated.

Parameters
args:List[Tuple[int, str]]Undocumented
template:OptionsUndocumented
Returns
Tuple[Dict[str, object], List[Tuple[int, str]]]Undocumented
def parse_section(prefix, template, set_strict_flags, section, config_types, stderr=sys.stderr): (source)

Parse one section of a config file.

Returns a dict of option values encountered, and a dict of report directories.

Parameters
prefix:strUndocumented
template:OptionsUndocumented
set​_strict​_flags:Callable[[], None]Undocumented
section:Mapping[str, Any]Undocumented
config​_types:Dict[str, Any]Undocumented
stderr:TextIOUndocumented
Returns
Tuple[Dict[str, object], Dict[str, str]]Undocumented
def parse_version(v): (source)

Undocumented

Parameters
v:strUndocumented
Returns
Tuple[int, int]Undocumented
def split_and_match_files(paths): (source)

Take a string representing a list of files/directories (with support for globbing through the glob library).

Where a path/glob matches no file, we still include the raw path in the resulting list.

Returns a list of file paths

Parameters
paths:strUndocumented
Returns
List[str]Undocumented
def split_and_match_files_list(paths): (source)

Take a list of files/directories (with support for globbing through the glob library).

Where a path/glob matches no file, we still include the raw path in the resulting list.

Returns a list of file paths

Parameters
paths:Sequence[str]Undocumented
Returns
List[str]Undocumented
def split_directive(s): (source)

Split s on commas, except during quoted sections.

Returns the parts and a list of error messages.

Parameters
s:strUndocumented
Returns
Tuple[List[str], List[str]]Undocumented
def try_split(v, split_regex='[,]'): (source)
Split and trim a str or list of str into a list of str
Parameters
v:Union[str, Sequence[str]]Undocumented
split​_regex:strUndocumented
Returns
List[str]Undocumented
ini_config_types: Dict[str, _INI_PARSER_CALLABLE] = (source)

Undocumented

Value
{'python_version': parse_version,
 'strict_optional_whitelist': (lambda s: s.split()),
 'custom_typing_module': str,
 'custom_typeshed_dir': expand_path,
 'mypy_path': (lambda s: [expand_path(p.strip()) for p in re.split('[,:]', s)]),
 'files': split_and_match_files,
 'quickstart_file': expand_path,
...
toml_config_types: Dict[str, _INI_PARSER_CALLABLE] = (source)

Undocumented

Value
ini_config_types.copy()
_CONFIG_VALUE_TYPES: _TypeAlias = (source)

Undocumented

Value
Union[str, bool, int, float, Dict[str, str], List[str], Tuple[int, int]]
_INI_PARSER_CALLABLE: _TypeAlias = (source)

Undocumented

Value
Callable[[Any], _CONFIG_VALUE_TYPES]