本文整理汇总了Python中mypy.options.Options.export_types方法的典型用法代码示例。如果您正苦于以下问题:Python Options.export_types方法的具体用法?Python Options.export_types怎么用?Python Options.export_types使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mypy.options.Options
的用法示例。
在下文中一共展示了Options.export_types方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_case
# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import export_types [as 别名]
def run_case(self, testcase: DataDrivenTestCase) -> None:
try:
line = testcase.input[0]
mask = ''
if line.startswith('##'):
mask = '(' + line[2:].strip() + ')$'
src = '\n'.join(testcase.input)
options = Options()
options.strict_optional = False # TODO: Enable strict optional checking
options.use_builtins_fixtures = True
options.show_traceback = True
options.export_types = True
result = build.build(sources=[BuildSource('main', None, src)],
options=options,
alt_lib_path=test_temp_dir)
a = result.errors
map = result.types
nodes = map.keys()
# Ignore NameExpr nodes of variables with explicit (trivial) types
# to simplify output.
searcher = SkippedNodeSearcher()
for file in result.files.values():
file.accept(searcher)
ignored = searcher.nodes
# Filter nodes that should be included in the output.
keys = []
for node in nodes:
if node.line is not None and node.line != -1 and map[node]:
if ignore_node(node) or node in ignored:
continue
if (re.match(mask, short_type(node))
or (isinstance(node, NameExpr)
and re.match(mask, node.name))):
# Include node in output.
keys.append(node)
for key in sorted(keys,
key=lambda n: (n.line, short_type(n),
str(n) + str(map[n]))):
ts = str(map[key]).replace('*', '') # Remove erased tags
ts = ts.replace('__main__.', '')
a.append('{}({}) : {}'.format(short_type(key), key.line, ts))
except CompileError as e:
a = e.messages
assert_string_arrays_equal(
testcase.output, a,
'Invalid type checker output ({}, line {})'.format(testcase.file,
testcase.line))