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 copy Undocumented
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​_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 is​_real​_errors Are there any generated errors (not just notes, for example)?
Method most​_recent​_error​_location Undocumented
Method new​_messages Return a string list of new error messages.
Method num​_messages Return the number of generated 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.
Method total​_errors Undocumented
Instance Variable disabled​_error​_codes Undocumented
Instance Variable enabled​_error​_codes Undocumented
Instance Variable error​_info​_map Undocumented
Instance Variable file Undocumented
Instance Variable flushed​_files Undocumented
Instance Variable function​_or​_member 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 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​_codes Undocumented
Instance Variable show​_error​_context Undocumented
Instance Variable target​_module Undocumented
Instance Variable used​_ignored​_lines Undocumented
Method _add​_error​_info Undocumented
def __init__(self, show_error_context=False, show_column_numbers=False, show_error_codes=False, pretty=False, read_source=None, show_absolute_path=False, enabled_error_codes=None, disabled_error_codes=None, many_errors_threshold=-1): (source)

Undocumented

Parameters
show​_error​_context:boolUndocumented
show​_column​_numbers:boolUndocumented
show​_error​_codes:boolUndocumented
pretty:boolUndocumented
read​_source:Optional[Callable[[str], Optional[List[str]]]]Undocumented
show​_absolute​_path:boolUndocumented
enabled​_error​_codes:Optional[Set[ErrorCode]]Undocumented
disabled​_error​_codes:Optional[Set[ErrorCode]]Undocumented
many​_errors​_threshold:intUndocumented
def add_error_info(self, info): (source)

Undocumented

Parameters
info:ErrorInfoUndocumented
def blocker_module(self): (source)
Return the module with a blocking error, or None if not possible.
Returns
Optional[str]Undocumented
def clear_errors_in_targets(self, path, targets): (source)
Remove errors in specific fine-grained targets within a file.
Parameters
path:strUndocumented
targets:Set[str]Undocumented
def copy(self): (source)

Undocumented

Returns
ErrorsUndocumented
def current_module(self): (source)

Undocumented

Returns
Optional[str]Undocumented
def current_target(self): (source)

Retrieves the current target from the associated scope.

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

Returns
Optional[str]Undocumented
def file_messages(self, path): (source)

Return a string list of new error messages from a given file.

Use a form suitable for displaying to the user.

Parameters
path:strUndocumented
Returns
List[str]Undocumented
def format_messages(self, error_info, source_lines): (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').

Parameters
error​_info:List[ErrorInfo]Undocumented
source​_lines:Optional[List[str]]Undocumented
Returns
List[str]Undocumented
def generate_unused_ignore_errors(self, file): (source)

Undocumented

Parameters
file:strUndocumented
def has_many_errors(self): (source)

Undocumented

Returns
boolUndocumented
def import_context(self): (source)
Return a copy of the import context.
Returns
List[Tuple[str, int]]Undocumented
def initialize(self): (source)

Undocumented

def is_blockers(self): (source)
Are the any errors that are blockers?
Returns
boolUndocumented
def is_error_code_enabled(self, error_code): (source)

Undocumented

Parameters
error​_code:ErrorCodeUndocumented
Returns
boolUndocumented
def is_errors(self): (source)
Are there any generated messages?
Returns
boolUndocumented
def is_errors_for_file(self, file): (source)
Are there any errors for the given file?
Parameters
file:strUndocumented
Returns
boolUndocumented
def is_ignored_error(self, line, info, ignores): (source)

Undocumented

Parameters
line:intUndocumented
info:ErrorInfoUndocumented
ignores:Dict[int, List[str]]Undocumented
Returns
boolUndocumented
def is_real_errors(self): (source)
Are there any generated errors (not just notes, for example)?
Returns
boolUndocumented
def most_recent_error_location(self): (source)

Undocumented

Returns
Tuple[int, int]Undocumented
def new_messages(self): (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.

Returns
List[str]Undocumented
def num_messages(self): (source)
Return the number of generated messages.
Returns
intUndocumented
def raise_error(self, use_stdout=True): (source)

Raise a CompileError with the generated messages.

Render the messages suitable for displaying.

Parameters
use​_stdout:boolUndocumented
def remove_duplicates(self, errors): (source)
Remove duplicates from a sorted error list.
Parameters
errors:List[ErrorTuple]Undocumented
Returns
List[ErrorTuple]Undocumented
def render_messages(self, errors): (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.

Parameters
errors:List[ErrorInfo]Undocumented
Returns
List[ErrorTuple]Undocumented
def report(self, line, column, message, code=None, *, blocker=False, severity='error', file=None, only_once=False, allow_dups=False, origin_line=None, offset=0, end_line=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_line: if non-None, override current context as origin end_line: if non-None, override current context as end
Parameters
line:intUndocumented
column:Optional[int]Undocumented
message:strUndocumented
code:Optional[ErrorCode]Undocumented
blocker:boolUndocumented
severity:strUndocumented
file:Optional[str]Undocumented
only​_once:boolUndocumented
allow​_dups:boolUndocumented
origin​_line:Optional[int]Undocumented
offset:intUndocumented
end​_line:Optional[int]Undocumented
def report_hidden_errors(self, info): (source)

Undocumented

Parameters
info:ErrorInfoUndocumented
def reset(self): (source)

Undocumented

def set_file(self, file, module, scope=None): (source)
Set the path and module id of the current file.
Parameters
file:strUndocumented
module:Optional[str]Undocumented
scope:Optional[Scope]Undocumented
def set_file_ignored_lines(self, file, ignored_lines, ignore_all=False): (source)

Undocumented

Parameters
file:strUndocumented
ignored​_lines:Dict[int, List[str]]Undocumented
ignore​_all:boolUndocumented
def set_ignore_prefix(self, prefix): (source)
Set path prefix that will be removed from all paths.
Parameters
prefix:strUndocumented
def set_import_context(self, ctx): (source)
Replace the entire import context with a new value.
Parameters
ctx:List[Tuple[str, int]]Undocumented
def simplify_path(self, file): (source)

Undocumented

Parameters
file:strUndocumented
Returns
strUndocumented
def sort_messages(self, errors): (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.

Parameters
errors:List[ErrorInfo]Undocumented
Returns
List[ErrorInfo]Undocumented
def targets(self): (source)
Return a set of all targets that contain errors.
Returns
Set[str]Undocumented
def total_errors(self): (source)

Undocumented

Returns
intUndocumented
disabled_error_codes = (source)

Undocumented

enabled_error_codes = (source)

Undocumented

error_info_map = (source)

Undocumented

file = (source)

Undocumented

flushed_files = (source)

Undocumented

function_or_member: list = (source)

Undocumented

ignore_prefix = (source)

Undocumented

ignored_files = (source)

Undocumented

ignored_lines = (source)

Undocumented

import_ctx = (source)

Undocumented

many_errors_threshold = (source)

Undocumented

only_once_messages = (source)

Undocumented

pretty = (source)

Undocumented

read_source = (source)

Undocumented

scope = (source)

Undocumented

seen_import_error: bool = (source)

Undocumented

show_absolute_path = (source)

Undocumented

show_column_numbers = (source)

Undocumented

show_error_codes = (source)

Undocumented

show_error_context = (source)

Undocumented

target_module = (source)

Undocumented

used_ignored_lines = (source)

Undocumented

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

Undocumented

Parameters
file:strUndocumented
info:ErrorInfoUndocumented