Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def acknowledge_lint_errors(
for error in lint_errors_to_process:
lint_errors_by_file[pathlib.Path(error.file)].append(error)

failed_files = []
for bad_file, errors_in_file in lint_errors_by_file.items():
_suppress_errors_in_file(bad_file, errors_in_file, encoding=DEFAULT_ENCODING)

Expand All @@ -131,15 +132,18 @@ def acknowledge_lint_errors(
if not changed: # are we done?
break
else:
raise RuntimeError(
failed_files.append(
f"Could not handle suppressions/formatting of file {bad_file} after maximum number of tries ({per_file_format_iteration_limit})"
)
_module_logger.warning("Max tries reached on %s", bad_file)
if failed_files:
raise RuntimeError("Could not handle some files:\n" + "\n\n".join(failed_files) + "\n\n\n")


def _remove_auto_suppressions_from_file(file):
lines = file.read_text(encoding=DEFAULT_ENCODING).splitlines()
stripped_lines = [_filter_suppresion_from_line(line) for line in lines]
file.write_text("\n".join(stripped_lines) + "\n")
file.write_text("\n".join(stripped_lines) + "\n", encoding=DEFAULT_ENCODING)


def _suppress_errors_in_file(bad_file, errors_in_file, encoding):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Parser:
"""Lint errors parser."""

__MATCHER = re.compile(
r"^(?P<file>[\w\\/\.]+):(?P<line>\d+):(?P<column>\d+): (?P<code>\w+) (?P<explanation>.+)"
r"^(?P<file>[\w\\/\.\-]+):(?P<line>\d+):(?P<column>\d+): (?P<code>\w+) (?P<explanation>.+)"
)

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ def __init__(self) -> None:
def problem_chars(self):
"""Return stored string with a unicode char."""
return self._problem_chars

def method_withBadName_andParams(my_normal_param, myBadlyNamedParam, my_other_Bad_param):
"""Provide example where black will want to split out result."""
return 5 + 7
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ def __init__(self) -> None:
def problem_chars(self):
"""Return stored string with a unicode char."""
return self._problem_chars

def method_withBadName_andParams(my_normal_param, myBadlyNamedParam, my_other_Bad_param): # noqa N802: function name 'method_withBadName_andParams' should be lowercase (auto-generated noqa) # noqa N803: argument name 'myBadlyNamedParam' should be lowercase (auto-generated noqa)
"""Provide example where black will want to split out result."""
return 5 + 7
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,12 @@ def __init__(self) -> None:
def problem_chars(self):
"""Return stored string with a unicode char."""
return self._problem_chars


def method_withBadName_andParams( # noqa N802: function name 'method_withBadName_andParams' should be lowercase (auto-generated noqa)
my_normal_param,
myBadlyNamedParam, # noqa N803: argument name 'myBadlyNamedParam' should be lowercase (auto-generated noqa)
my_other_Bad_param,
):
"""Provide example where black will want to split out result."""
return 5 + 7
1 change: 1 addition & 0 deletions tests/test_cli/test_lint_errors_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
r".\source\lorem.py:33:12: E713 test for membership should be 'not in'",
r".\source\lorem.py:43:5: F811 redefinition of unused 'argparse' from line 7",
r".\source\lorem.py:169:30: F821 undefined name 'option_values'",
r".\source\lorem-name_with_other_valid_chars_in_it.py:169:30: F821 undefined name 'option_values'",
r".\source\lorem.py:33:9: F402 import 'entry' from line 8 shadowed by loop variable",
r".\source\lorem.py:157:9: E722 do not use bare 'except'",
r".\source\lorem.py:6:1: F403 'from ipsum import *' used; unable to detect undefined names",
Expand Down