示例#1
0
def test__linter__linting_result__combine_dicts():
    """Test the combination of dictionaries in the linter."""
    lr = LintingResult()
    a = dict(a=3, b=123, f=876.321)
    b = dict(h=19, i=321.0, j=23478)
    r = dict(z=22)
    assert lr.combine_dicts(a, b, r) == dict(
        a=3, b=123, f=876.321, h=19, i=321.0, j=23478, z=22
    )
示例#2
0
def test__linter__linting_result__sum_dicts():
    """Test the summing of dictionaries in the linter."""
    lr = LintingResult()
    i = {}
    a = dict(a=3, b=123, f=876.321)
    b = dict(a=19, b=321.0, g=23478)
    r = dict(a=22, b=444.0, f=876.321, g=23478)
    assert lr.sum_dicts(a, b) == r
    # Check the identity too
    assert lr.sum_dicts(r, i) == r
示例#3
0
def _handle_files_with_tmp_or_prs_errors(lint_result: LintingResult) -> int:
    """Discard lint fixes for files with templating or parse errors.

    Returns 1 if there are any files with templating or parse errors after
    filtering, else 0. (Intended as a process exit code.)
    """
    total_errors, num_filtered_errors = lint_result.count_tmp_prs_errors()
    lint_result.discard_fixes_for_lint_errors_in_files_with_tmp_or_prs_errors()
    if total_errors:
        click.echo(
            colorize(f"  [{total_errors} templating/parsing errors found]",
                     Color.red))
        if num_filtered_errors < total_errors:
            color = Color.red if num_filtered_errors else Color.green
            click.echo(
                colorize(
                    f"  [{num_filtered_errors} templating/parsing errors "
                    f'remaining after "ignore"]',
                    color,
                ))
    return 1 if num_filtered_errors else 0