本文整理汇总了Python中mypy.errors.Errors.set_ignore_prefix方法的典型用法代码示例。如果您正苦于以下问题:Python Errors.set_ignore_prefix方法的具体用法?Python Errors.set_ignore_prefix怎么用?Python Errors.set_ignore_prefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mypy.errors.Errors
的用法示例。
在下文中一共展示了Errors.set_ignore_prefix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: directory
# 需要导入模块: from mypy.errors import Errors [as 别名]
# 或者: from mypy.errors.Errors import set_ignore_prefix [as 别名]
class BuildManager:
"""This is the central class for building a mypy program.
It coordinates parsing, import processing, semantic analysis and
type checking. It manages state objects that actually perform the
build steps.
Attributes:
data_dir: Mypy data directory (contains stubs)
target: Build target; selects which passes to perform
lib_path: Library path for looking up modules
semantic_analyzer:
Semantic analyzer, pass 2
semantic_analyzer_pass3:
Semantic analyzer, pass 3
type_checker: Type checker
errors: Used for reporting all errors
pyversion: Python version (major, minor)
flags: Build options
states: States of all individual files that are being
processed. Each file in a build is always represented
by a single state object (after it has been encountered
for the first time). This is the only place where
states are stored.
module_files: Map from module name to source file path. There is a
1:1 mapping between modules and source files.
module_deps: Cache for module dependencies (direct or indirect).
Item (m, n) indicates whether m depends on n (directly
or indirectly).
missing_modules: Set of modules that could not be imported encountered so far
"""
def __init__(self, data_dir: str,
lib_path: List[str],
target: int,
pyversion: Tuple[int, int],
flags: List[str],
ignore_prefix: str,
custom_typing_module: str,
reports: Reports) -> None:
self.data_dir = data_dir
self.errors = Errors()
self.errors.set_ignore_prefix(ignore_prefix)
self.lib_path = lib_path
self.target = target
self.pyversion = pyversion
self.flags = flags
self.custom_typing_module = custom_typing_module
self.reports = reports
self.semantic_analyzer = SemanticAnalyzer(lib_path, self.errors,
pyversion=pyversion)
modules = self.semantic_analyzer.modules
self.semantic_analyzer_pass3 = ThirdPass(modules, self.errors)
self.type_checker = TypeChecker(self.errors, modules, self.pyversion)
self.states = [] # type: List[State]
self.module_files = {} # type: Dict[str, str]
self.module_deps = {} # type: Dict[Tuple[str, str], bool]
self.missing_modules = set() # type: Set[str]
def process(self, initial_states: List['UnprocessedFile']) -> BuildResult:
"""Perform a build.
The argument is a state that represents the main program
file. This method should only be called once per a build
manager object. The return values are identical to the return
values of the build function.
"""
self.states += initial_states
for initial_state in initial_states:
self.module_files[initial_state.id] = initial_state.path
for initial_state in initial_states:
initial_state.load_dependencies()
# Process states in a loop until all files (states) have been
# semantically analyzed or type checked (depending on target).
#
# We type check all files before the rest of the passes so that we can
# report errors and fail as quickly as possible.
while True:
# Find the next state that has all its dependencies met.
next = self.next_available_state()
if not next:
trace('done')
break
# Potentially output some debug information.
trace('next {} ({})'.format(next.path, next.state()))
# Set the import context for reporting error messages correctly.
self.errors.set_import_context(next.import_context)
# Process the state. The process method is reponsible for adding a
# new state object representing the new state of the file.
next.process()
# Raise exception if the build failed. The build can fail for
# various reasons, such as parse error, semantic analysis error,
# etc.
if self.errors.is_blockers():
self.errors.raise_error()
#.........这里部分代码省略.........
示例2: directory
# 需要导入模块: from mypy.errors import Errors [as 别名]
# 或者: from mypy.errors.Errors import set_ignore_prefix [as 别名]
class BuildManager:
"""This is the central class for building a mypy program.
It coordinates parsing, import processing, semantic analysis and
type checking. It manages state objects that actually perform the
build steps.
Attributes:
data_dir: Mypy data directory (contains stubs)
target: Build target; selects which passes to perform
lib_path: Library path for looking up modules
semantic_analyzer:
Semantic analyzer, pass 2
semantic_analyzer_pass3:
Semantic analyzer, pass 3
type_checker: Type checker
errors: Used for reporting all errors
output_dir: Store output files here (Python)
pyversion: Python version (2 or 3)
flags: Build options
states: States of all individual files that are being
processed. Each file in a build is always represented
by a single state object (after it has been encountered
for the first time). This is the only place where
states are stored.
module_files: Map from module name to source file path. There is a
1:1 mapping between modules and source files.
icode: Generated icode (when compiling via C)
binary_path: Path of the generated binary (or None)
module_deps: Cache for module dependencies (direct or indirect).
Item (m, n) indicates whether m depends on n (directly
or indirectly).
TODO Refactor code related to transformation, icode generation etc. to
external objects. This module should not directly depend on them.
"""
def __init__(self, data_dir: str,
lib_path: List[str],
target: int,
output_dir: str,
pyversion: int,
flags: List[str],
ignore_prefix: str) -> None:
self.data_dir = data_dir
self.errors = Errors()
self.errors.set_ignore_prefix(ignore_prefix)
self.lib_path = lib_path
self.target = target
self.output_dir = output_dir
self.pyversion = pyversion
self.flags = flags
self.semantic_analyzer = SemanticAnalyzer(lib_path, self.errors)
self.semantic_analyzer_pass3 = ThirdPass(self.errors)
self.type_checker = TypeChecker(self.errors,
self.semantic_analyzer.modules,
self.pyversion)
self.states = List[State]()
self.module_files = Dict[str, str]()
self.icode = Dict[str, FuncIcode]()
self.binary_path = None # type: str
self.module_deps = Dict[Tuple[str, str], bool]()
def process(self, initial_state: 'UnprocessedFile') -> BuildResult:
"""Perform a build.
The argument is a state that represents the main program
file. This method should only be called once per a build
manager object. The return values are identical to the return
values of the build function.
"""
self.states.append(initial_state)
# Process states in a loop until all files (states) have been
# semantically analyzed or type checked (depending on target).
#
# We type check all files before the rest of the passes so that we can
# report errors and fail as quickly as possible.
while True:
# Find the next state that has all its dependencies met.
next = self.next_available_state()
if not next:
trace('done')
break
# Potentially output some debug information.
trace('next {} ({})'.format(next.path, next.state()))
# Set the import context for reporting error messages correctly.
self.errors.set_import_context(next.import_context)
# Process the state. The process method is reponsible for adding a
# new state object representing the new state of the file.
next.process()
# Raise exception if the build failed. The build can fail for
# various reasons, such as parse error, semantic analysis error,
# etc.
if self.errors.is_errors():
self.errors.raise_error()
#.........这里部分代码省略.........