class documentation

class BuildManager: (source)

View In Hierarchy

This class holds shared state for building a mypy program.

It is used to coordinate parsing, import processing, semantic analysis and type checking. The actual build steps are carried out by dispatch().

Attributes:

data_dir: Mypy data directory (contains stubs) search_paths: SearchPaths instance indicating where to look for modules modules: Mapping of module ID to MypyFile (shared by the passes) semantic_analyzer:

Semantic analyzer, pass 2
semantic_analyzer_pass3:
Semantic analyzer, pass 3

all_types: Map {Expression: Type} from all modules (enabled by export_types) options: Build options missing_modules: Set of modules that could not be imported encountered so far stale_modules: Set of modules that needed to be rechecked (only used by tests) fg_deps_meta: Metadata for fine-grained dependencies caches associated with modules fg_deps: A fine-grained dependency map version_id: The current mypy version (based on commit id when possible) plugin: Active mypy plugin(s) plugins_snapshot:

Snapshot of currently active user plugins (versions and hashes)
old_plugins_snapshot:
Plugins snapshot from previous incremental run (or None in non-incremental mode and if cache was not found)

errors: Used for reporting all errors flush_errors: A function for processing errors after each SCC cache_enabled: Whether cache is being read. This is set based on options,

but is disabled if fine-grained cache loading fails and after an initial fine-grained load. This doesn't determine whether we write cache files or not.
quickstart_state:
A cache of filename -> mtime/size/hash info used to avoid needing to hash source files when using a cache with mismatching mtimes
stats: Dict with various instrumentation numbers, it is used
not only for debugging, but also required for correctness, in particular to check consistency of the fine-grained dependency cache.

fscache: A file system cacher ast_cache: AST cache to speed up mypy daemon

Method __init__ Undocumented
Method add​_stats Undocumented
Method all​_imported​_modules​_in​_file Find all reachable import statements in a file.
Method dump​_stats Undocumented
Method get​_stat Undocumented
Method getmtime Return a file's mtime; but 0 in bazel mode.
Method is​_module Is there a file in the file system corresponding to module id?
Method load​_fine​_grained​_deps Undocumented
Method log Undocumented
Method log​_fine​_grained Undocumented
Method maybe​_swap​_for​_shadow​_path Undocumented
Method parse​_file Parse the source of a file with the given name.
Method report​_file Undocumented
Method stats​_summary Undocumented
Method trace Undocumented
Method use​_fine​_grained​_cache Undocumented
Method verbosity Undocumented
Instance Variable all​_types Undocumented
Instance Variable ast​_cache Undocumented
Instance Variable cache​_enabled Undocumented
Instance Variable data​_dir Undocumented
Instance Variable errors Undocumented
Instance Variable fg​_deps Undocumented
Instance Variable fg​_deps​_meta Undocumented
Instance Variable find​_module​_cache Undocumented
Instance Variable flush​_errors Undocumented
Instance Variable fscache Undocumented
Instance Variable incomplete​_namespaces Undocumented
Instance Variable indirection​_detector Undocumented
Instance Variable metastore Undocumented
Instance Variable missing​_modules Undocumented
Instance Variable missing​_stub​_packages Undocumented
Instance Variable modules Undocumented
Instance Variable old​_plugins​_snapshot Undocumented
Instance Variable options Undocumented
Instance Variable plugin Undocumented
Instance Variable plugins​_snapshot Undocumented
Instance Variable processed​_targets Undocumented
Instance Variable quickstart​_state Undocumented
Instance Variable rechecked​_modules Undocumented
Instance Variable reports Undocumented
Instance Variable search​_paths Undocumented
Instance Variable semantic​_analyzer Undocumented
Instance Variable shadow​_equivalence​_map Undocumented
Instance Variable shadow​_map Undocumented
Instance Variable source​_set Undocumented
Instance Variable stale​_modules Undocumented
Instance Variable start​_time Undocumented
Instance Variable stats Undocumented
Instance Variable stderr Undocumented
Instance Variable stdout Undocumented
Instance Variable version​_id Undocumented
def __init__(self, data_dir, search_paths, ignore_prefix, source_set, reports, options, version_id, plugin, plugins_snapshot, errors, flush_errors, fscache, stdout, stderr): (source)

Undocumented

Parameters
data​_dir:strUndocumented
search​_paths:SearchPathsUndocumented
ignore​_prefix:strUndocumented
source​_set:BuildSourceSetUndocumented
reports:Optional[Reports]Undocumented
options:OptionsUndocumented
version​_id:strUndocumented
plugin:PluginUndocumented
plugins​_snapshot:Dict[str, str]Undocumented
errors:ErrorsUndocumented
flush​_errors:Callable[[List[str], bool], None]Undocumented
fscache:FileSystemCacheUndocumented
stdout:TextIOUndocumented
stderr:TextIOUndocumented
def add_stats(self, **kwds): (source)

Undocumented

Parameters
**kwds:AnyUndocumented
def all_imported_modules_in_file(self, file): (source)

Find all reachable import statements in a file.

Return list of tuples (priority, module id, import line number) for all modules imported in file; lower numbers == higher priority.

Can generate blocking errors on bogus relative imports.

Parameters
file:MypyFileUndocumented
Returns
List[Tuple[int, str, int]]Undocumented
def dump_stats(self): (source)

Undocumented

def get_stat(self, path): (source)

Undocumented

Parameters
path:strUndocumented
Returns
os.stat_resultUndocumented
def getmtime(self, path): (source)

Return a file's mtime; but 0 in bazel mode.

(Bazel's distributed cache doesn't like filesystem metadata to end up in output files.)

Parameters
path:strUndocumented
Returns
intUndocumented
def is_module(self, id): (source)
Is there a file in the file system corresponding to module id?
Parameters
id:strUndocumented
Returns
boolUndocumented
def load_fine_grained_deps(self, id): (source)

Undocumented

Parameters
id:strUndocumented
Returns
Dict[str, Set[str]]Undocumented
def log(self, *message): (source)

Undocumented

Parameters
*message:strUndocumented
def log_fine_grained(self, *message): (source)

Undocumented

Parameters
*message:strUndocumented
def maybe_swap_for_shadow_path(self, path): (source)

Undocumented

Parameters
path:strUndocumented
Returns
strUndocumented
def parse_file(self, id, path, source, ignore_errors, options): (source)

Parse the source of a file with the given name.

Raise CompileError if there is a parse error.

Parameters
id:strUndocumented
path:strUndocumented
source:strUndocumented
ignore​_errors:boolUndocumented
options:OptionsUndocumented
Returns
MypyFileUndocumented
def report_file(self, file, type_map, options): (source)

Undocumented

Parameters
file:MypyFileUndocumented
type​_map:Dict[Expression, Type]Undocumented
options:OptionsUndocumented
def stats_summary(self): (source)

Undocumented

Returns
Mapping[str, object]Undocumented
def trace(self, *message): (source)

Undocumented

Parameters
*message:strUndocumented
def use_fine_grained_cache(self): (source)

Undocumented

Returns
boolUndocumented
def verbosity(self): (source)

Undocumented

Returns
intUndocumented
all_types: Dict[Expression, Type] = (source)

Undocumented

ast_cache: Dict[str, Tuple[MypyFile, List[ErrorInfo]]] = (source)

Undocumented

cache_enabled = (source)

Undocumented

data_dir = (source)

Undocumented

errors = (source)

Undocumented

fg_deps: Dict[str, Set[str]] = (source)

Undocumented

fg_deps_meta: Dict[str, FgDepMeta] = (source)

Undocumented

find_module_cache = (source)

Undocumented

flush_errors = (source)

Undocumented

fscache = (source)

Undocumented

incomplete_namespaces: Set[str] = (source)

Undocumented

indirection_detector = (source)

Undocumented

metastore = (source)

Undocumented

missing_modules: Set[str] = (source)

Undocumented

missing_stub_packages: Set[str] = (source)

Undocumented

modules: Dict[str, MypyFile] = (source)

Undocumented

old_plugins_snapshot = (source)

Undocumented

options = (source)

Undocumented

plugin = (source)

Undocumented

plugins_snapshot = (source)

Undocumented

processed_targets: List[str] = (source)

Undocumented

quickstart_state = (source)

Undocumented

rechecked_modules: Set[str] = (source)

Undocumented

reports = (source)

Undocumented

search_paths = (source)

Undocumented

semantic_analyzer = (source)

Undocumented

shadow_equivalence_map: Dict[str, Optional[str]] = (source)

Undocumented

shadow_map = (source)

Undocumented

source_set = (source)

Undocumented

stale_modules: Set[str] = (source)

Undocumented

start_time = (source)

Undocumented

stats: Dict[str, Any] = (source)

Undocumented

stderr = (source)

Undocumented

stdout = (source)

Undocumented

version_id = (source)

Undocumented