class documentation

class Errors: (source)

View In Hierarchy

Container for compile errors. This class generates and keeps tracks of compile errors and the current error context (nested imports).

Method __init__ Undocumented
Method add_error_info Undocumented
Method blocker_module Return the module with a blocking error, or None if not possible.
Method clear_errors_in_targets Remove errors in specific fine-grained targets within a file.
Method current_module Undocumented
Method current_target Retrieves the current target from the associated scope.
Method file_messages Return a string list of new error messages from a given file.
Method format_messages Return a string list that represents the error messages.
Method generate_ignore_without_code_errors Undocumented
Method generate_unused_ignore_errors Undocumented
Method has_many_errors Undocumented
Method import_context Return a copy of the import context.
Method initialize Undocumented
Method is_blockers Are the any errors that are blockers?
Method is_error_code_enabled Undocumented
Method is_errors Are there any generated messages?
Method is_errors_for_file Are there any errors for the given file?
Method is_ignored_error Undocumented
Method new_messages Return a string list of new error messages.
Method num_messages Return the number of generated messages.
Method prefer_simple_messages Should we generate simple/fast error messages?
Method raise_error Raise a CompileError with the generated messages.
Method remove_duplicates Remove duplicates from a sorted error list.
Method render_messages Translate the messages into a sequence of tuples.
Method report Report message at the given line using the current error context.
Method report_hidden_errors Undocumented
Method reset Undocumented
Method set_file Set the path and module id of the current file.
Method set_file_ignored_lines Undocumented
Method set_ignore_prefix Set path prefix that will be removed from all paths.
Method set_import_context Replace the entire import context with a new value.
Method simplify_path Undocumented
Method sort_messages Sort an array of error messages locally by line number.
Method targets Return a set of all targets that contain errors.
Instance Variable error_info_map Undocumented
Instance Variable file Undocumented
Instance Variable flushed_files Undocumented
Instance Variable function_or_member Undocumented
Instance Variable has_blockers Undocumented
Instance Variable hide_error_codes Undocumented
Instance Variable ignore_prefix Undocumented
Instance Variable ignored_files Undocumented
Instance Variable ignored_lines Undocumented
Instance Variable import_ctx Undocumented
Instance Variable many_errors_threshold Undocumented
Instance Variable only_once_messages Undocumented
Instance Variable options Undocumented
Instance Variable pretty Undocumented
Instance Variable read_source Undocumented
Instance Variable scope Undocumented
Instance Variable seen_import_error Undocumented
Instance Variable show_absolute_path Undocumented
Instance Variable show_column_numbers Undocumented
Instance Variable show_error_context Undocumented
Instance Variable show_error_end Undocumented
Instance Variable target_module Undocumented
Instance Variable used_ignored_lines Undocumented
Method _add_error_info Undocumented
Method _filter_error process ErrorWatcher stack from top to bottom, stopping early if error needs to be filtered out
Class Variable _watchers Undocumented
def __init__(self, show_error_context: bool = False, show_column_numbers: bool = False, hide_error_codes: bool = False, pretty: bool = False, show_error_end: bool = False, read_source: Callable[[str], list[str]|None]|None = None, show_absolute_path: bool = False, many_errors_threshold: int = -1, options: Options|None = None): (source)

Undocumented

def add_error_info(self, info: ErrorInfo): (source)

Undocumented

def blocker_module(self) -> str|None: (source)

Return the module with a blocking error, or None if not possible.

def clear_errors_in_targets(self, path: str, targets: set[str]): (source)

Remove errors in specific fine-grained targets within a file.

def current_module(self) -> str|None: (source)

Undocumented

def current_target(self) -> str|None: (source)

Retrieves the current target from the associated scope. If there is no associated scope, use the target module.

def file_messages(self, path: str) -> list[str]: (source)

Return a string list of new error messages from a given file. Use a form suitable for displaying to the user.

def format_messages(self, error_info: list[ErrorInfo], source_lines: list[str]|None) -> list[str]: (source)

Return a string list that represents the error messages. Use a form suitable for displaying to the user. If self.pretty is True also append a relevant trimmed source code line (only for severity 'error').

def generate_ignore_without_code_errors(self, file: str, is_warning_unused_ignores: bool): (source)

Undocumented

def generate_unused_ignore_errors(self, file: str): (source)

Undocumented

def has_many_errors(self) -> bool: (source)

Undocumented

def import_context(self) -> list[tuple[str, int]]: (source)

Return a copy of the import context.

def initialize(self): (source)

Undocumented

def is_blockers(self) -> bool: (source)

Are the any errors that are blockers?

def is_error_code_enabled(self, error_code: ErrorCode) -> bool: (source)

Undocumented

def is_errors(self) -> bool: (source)

Are there any generated messages?

def is_errors_for_file(self, file: str) -> bool: (source)

Are there any errors for the given file?

def is_ignored_error(self, line: int, info: ErrorInfo, ignores: dict[int, list[str]]) -> bool: (source)

Undocumented

def new_messages(self) -> list[str]: (source)

Return a string list of new error messages. Use a form suitable for displaying to the user. Errors from different files are ordered based on the order in which they first generated an error.

def num_messages(self) -> int: (source)

Return the number of generated messages.

def prefer_simple_messages(self) -> bool: (source)

Should we generate simple/fast error messages? Return True if errors are not shown to user, i.e. errors are ignored or they are collected for internal use only. If True, we should prefer to generate a simple message quickly. All normal errors should still be reported.

def raise_error(self, use_stdout: bool = True) -> NoReturn: (source)

Raise a CompileError with the generated messages. Render the messages suitable for displaying.

def remove_duplicates(self, errors: list[ErrorTuple]) -> list[ErrorTuple]: (source)

Remove duplicates from a sorted error list.

def render_messages(self, errors: list[ErrorInfo]) -> list[ErrorTuple]: (source)

Translate the messages into a sequence of tuples. Each tuple is of form (path, line, col, severity, message, allow_dups, code). The rendered sequence includes information about error contexts. The path item may be None. If the line item is negative, the line number is not defined for the tuple.

def report(self, line: int, column: int|None, message: str, code: ErrorCode|None = None, *, blocker: bool = False, severity: str = 'error', file: str|None = None, only_once: bool = False, allow_dups: bool = False, origin_span: Iterable[int]|None = None, offset: int = 0, end_line: int|None = None, end_column: int|None = None): (source)

Report message at the given line using the current error context. Args: line: line number of error column: column number of error message: message to report code: error code (defaults to 'misc'; not shown for notes) blocker: if True, don't continue analysis after this error severity: 'error' or 'note' file: if non-None, override current file as context only_once: if True, only report this exact message once per build allow_dups: if True, allow duplicate copies of this message (ignored if only_once) origin_span: if non-None, override current context as origin (type: ignores have effect here) end_line: if non-None, override current context as end

def report_hidden_errors(self, info: ErrorInfo): (source)

Undocumented

def reset(self): (source)

Undocumented

def set_file(self, file: str, module: str|None, options: Options, scope: Scope|None = None): (source)

Set the path and module id of the current file.

def set_file_ignored_lines(self, file: str, ignored_lines: dict[int, list[str]], ignore_all: bool = False): (source)

Undocumented

def set_ignore_prefix(self, prefix: str): (source)

Set path prefix that will be removed from all paths.

def set_import_context(self, ctx: list[tuple[str, int]]): (source)

Replace the entire import context with a new value.

def simplify_path(self, file: str) -> str: (source)

Undocumented

def sort_messages(self, errors: list[ErrorInfo]) -> list[ErrorInfo]: (source)

Sort an array of error messages locally by line number. I.e., sort a run of consecutive messages with the same context by line number, but otherwise retain the general ordering of the messages.

def targets(self) -> set[str]: (source)

Return a set of all targets that contain errors.

error_info_map: dict = (source)

Undocumented

Undocumented

flushed_files = (source)

Undocumented

function_or_member: list = (source)

Undocumented

has_blockers = (source)

Undocumented

hide_error_codes = (source)

Undocumented

ignore_prefix = (source)

Undocumented

ignored_files = (source)

Undocumented

ignored_lines: dict = (source)

Undocumented

import_ctx = (source)

Undocumented

many_errors_threshold = (source)

Undocumented

only_once_messages = (source)

Undocumented

Undocumented

Undocumented

read_source = (source)

Undocumented

Undocumented

seen_import_error: bool = (source)

Undocumented

show_absolute_path = (source)

Undocumented

show_column_numbers = (source)

Undocumented

show_error_context = (source)

Undocumented

show_error_end = (source)

Undocumented

target_module = (source)

Undocumented

used_ignored_lines = (source)

Undocumented

def _add_error_info(self, file: str, info: ErrorInfo): (source)

Undocumented

def _filter_error(self, file: str, info: ErrorInfo) -> bool: (source)

process ErrorWatcher stack from top to bottom, stopping early if error needs to be filtered out

Undocumented