本文整理汇总了Python中mypy.options.Options.use_builtins_fixtures方法的典型用法代码示例。如果您正苦于以下问题:Python Options.use_builtins_fixtures方法的具体用法?Python Options.use_builtins_fixtures怎么用?Python Options.use_builtins_fixtures使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mypy.options.Options
的用法示例。
在下文中一共展示了Options.use_builtins_fixtures方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_semanal_options
# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import use_builtins_fixtures [as 别名]
def get_semanal_options() -> Options:
options = Options()
options.use_builtins_fixtures = True
options.semantic_analysis_only = True
options.show_traceback = True
options.python_version = PYTHON3_VERSION
return options
示例2: parse_options
# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import use_builtins_fixtures [as 别名]
def parse_options(self, program_text: str, testcase: DataDrivenTestCase,
incremental_step: int) -> Options:
options = Options()
flags = re.search('# flags: (.*)$', program_text, flags=re.MULTILINE)
if incremental_step > 1:
flags2 = re.search('# flags{}: (.*)$'.format(incremental_step), program_text,
flags=re.MULTILINE)
if flags2:
flags = flags2
flag_list = None
if flags:
flag_list = flags.group(1).split()
targets, options = process_options(flag_list, require_targets=False)
if targets:
raise RuntimeError('Specifying targets via the flags pragma is not supported.')
else:
options = Options()
# Allow custom python version to override testcase_pyversion
if (not flag_list or
all(flag not in flag_list for flag in ['--python-version', '-2', '--py2'])):
options.python_version = testcase_pyversion(testcase.file, testcase.name)
options.use_builtins_fixtures = True
options.show_traceback = True
options.incremental = True
return options
示例3: build
# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import use_builtins_fixtures [as 别名]
def build(self, source: str) -> Tuple[List[str], Optional[Dict[str, MypyFile]]]:
options = Options()
options.use_builtins_fixtures = True
options.show_traceback = True
options.cache_dir = os.devnull
try:
result = build.build(sources=[BuildSource('main', None, source)],
options=options,
alt_lib_path=test_temp_dir)
except CompileError as e:
# TODO: Is it okay to return None?
return e.messages, None
return result.errors, result.files
示例4: run_case
# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import use_builtins_fixtures [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))
示例5: build
# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import use_builtins_fixtures [as 别名]
def build(self, source: str) -> Tuple[List[str], Optional[BuildManager], Dict[str, State]]:
options = Options()
options.incremental = True
options.use_builtins_fixtures = True
options.show_traceback = True
main_path = os.path.join(test_temp_dir, 'main')
with open(main_path, 'w') as f:
f.write(source)
try:
result = build.build(sources=[BuildSource(main_path, None, None)],
options=options,
alt_lib_path=test_temp_dir)
except CompileError as e:
# TODO: Is it okay to return None?
return e.messages, None, {}
return result.errors, result.manager, result.graph
示例6: build
# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import use_builtins_fixtures [as 别名]
def build(self,
source: str,
python_version: Tuple[int, int]) -> Tuple[List[str],
Optional[Dict[str, MypyFile]],
Optional[Dict[Expression, Type]]]:
options = Options()
options.use_builtins_fixtures = True
options.show_traceback = True
options.cache_dir = os.devnull
options.python_version = python_version
try:
result = build.build(sources=[BuildSource('main', None, source)],
options=options,
alt_lib_path=test_temp_dir)
except CompileError as e:
# TODO: Should perhaps not return None here.
return e.messages, None, None
return result.errors, result.files, result.types
示例7: build
# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import use_builtins_fixtures [as 别名]
def build(self, source: str) -> Optional[BuildResult]:
options = Options()
options.incremental = True
options.fine_grained_incremental = True
options.use_builtins_fixtures = True
options.show_traceback = True
options.python_version = PYTHON3_VERSION
main_path = os.path.join(test_temp_dir, 'main')
with open(main_path, 'w', encoding='utf8') as f:
f.write(source)
try:
result = build.build(sources=[BuildSource(main_path, None, None)],
options=options,
alt_lib_path=test_temp_dir)
except CompileError:
# TODO: Is it okay to return None?
return None
return result
示例8: test_transform
# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import use_builtins_fixtures [as 别名]
def test_transform(testcase: DataDrivenTestCase) -> None:
"""Perform an identity transform test case."""
try:
src = '\n'.join(testcase.input)
options = Options()
options.use_builtins_fixtures = True
options.semantic_analysis_only = True
options.show_traceback = True
options.python_version = testfile_pyversion(testcase.file)
result = build.build(sources=[BuildSource('main', None, src)],
options=options,
alt_lib_path=test_temp_dir)
a = result.errors
if a:
raise CompileError(a)
# Include string representations of the source files in the actual
# output.
for fnam in sorted(result.files.keys()):
f = result.files[fnam]
# Omit the builtins module and files with a special marker in the
# path.
# TODO the test is not reliable
if (not f.path.endswith((os.sep + 'builtins.pyi',
'typing.pyi',
'abc.pyi'))
and not os.path.basename(f.path).startswith('_')
and not os.path.splitext(
os.path.basename(f.path))[0].endswith('_')):
t = TypeAssertTransformVisitor()
f = t.mypyfile(f)
a += str(f).split('\n')
except CompileError as e:
a = e.messages
if testcase.normalize_output:
a = normalize_error_messages(a)
assert_string_arrays_equal(
testcase.output, a,
'Invalid semantic analyzer output ({}, line {})'.format(testcase.file,
testcase.line))
示例9: get_semanal_options
# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import use_builtins_fixtures [as 别名]
def get_semanal_options():
options = Options()
options.use_builtins_fixtures = True
options.semantic_analysis_only = True
return options
示例10: get_semanal_options
# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import use_builtins_fixtures [as 别名]
def get_semanal_options() -> Options:
options = Options()
options.use_builtins_fixtures = True
options.semantic_analysis_only = True
options.show_traceback = True
return options