本文整理汇总了Python中mypy.options.Options.unused_configs[pattern]方法的典型用法代码示例。如果您正苦于以下问题:Python Options.unused_configs[pattern]方法的具体用法?Python Options.unused_configs[pattern]怎么用?Python Options.unused_configs[pattern]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mypy.options.Options
的用法示例。
在下文中一共展示了Options.unused_configs[pattern]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_config_file
# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import unused_configs[pattern] [as 别名]
def parse_config_file(options: Options, filename: Optional[str]) -> None:
"""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 file and then
to setup.cfg.
"""
if filename is not None:
config_files = (filename,) # type: Tuple[str, ...]
else:
config_files = (defaults.CONFIG_FILE,) + SHARED_CONFIG_FILES
parser = configparser.RawConfigParser()
for config_file in config_files:
if not os.path.exists(config_file):
continue
try:
parser.read(config_file)
except configparser.Error as err:
print("%s: %s" % (config_file, err), file=sys.stderr)
else:
file_read = config_file
options.config_file = file_read
break
else:
return
if 'mypy' not in parser:
if filename or file_read not in SHARED_CONFIG_FILES:
print("%s: No [mypy] section in config file" % file_read, file=sys.stderr)
else:
section = parser['mypy']
prefix = '%s: [%s]' % (file_read, 'mypy')
updates, report_dirs = parse_section(prefix, options, section)
for k, v in updates.items():
setattr(options, k, v)
options.report_dirs.update(report_dirs)
for name, section in parser.items():
if name.startswith('mypy-'):
prefix = '%s: [%s]' % (file_read, name)
updates, report_dirs = parse_section(prefix, options, section)
if report_dirs:
print("%s: Per-module sections should not specify reports (%s)" %
(prefix, ', '.join(s + '_report' for s in sorted(report_dirs))),
file=sys.stderr)
if set(updates) - Options.PER_MODULE_OPTIONS:
print("%s: Per-module sections should only specify per-module flags (%s)" %
(prefix, ', '.join(sorted(set(updates) - Options.PER_MODULE_OPTIONS))),
file=sys.stderr)
updates = {k: v for k, v in updates.items() if k in Options.PER_MODULE_OPTIONS}
globs = name[5:]
for glob in globs.split(','):
# For backwards compatibility, replace (back)slashes with dots.
glob = glob.replace(os.sep, '.')
if os.altsep:
glob = glob.replace(os.altsep, '.')
pattern = re.compile(fnmatch.translate(glob))
options.per_module_options[pattern] = updates
options.unused_configs[pattern] = glob