extend black formatting to tests as well

This commit is contained in:
Anthony Sottile 2021-04-18 09:17:48 -07:00
parent a7174759e9
commit af1668bf04
45 changed files with 1644 additions and 1307 deletions

View file

@ -17,9 +17,7 @@ LOG = logging.getLogger(__name__)
LOG.addHandler(logging.NullHandler())
__version__ = "3.9.1"
__version_info__ = tuple(
int(i) for i in __version__.split(".") if i.isdigit()
)
__version_info__ = tuple(int(i) for i in __version__.split(".") if i.isdigit())
# There is nothing lower than logging.DEBUG (10) in the logging library,

View file

@ -241,9 +241,7 @@ class Manager:
"""
results_reported = results_found = 0
for checker in self._all_checkers:
results = sorted(
checker.results, key=lambda tup: (tup[1], tup[2])
)
results = sorted(checker.results, key=lambda tup: (tup[1], tup[2]))
filename = checker.display_name
with self.style_guide.processing_file(filename):
results_reported += self._handle_results(filename, results)

View file

@ -39,9 +39,7 @@ class InvalidSyntax(Flake8Exception):
def __init__(self, exception: Exception) -> None:
"""Initialize our InvalidSyntax exception."""
self.original_exception = exception
self.error_message = (
f"{type(exception).__name__}: {exception.args[0]}"
)
self.error_message = f"{type(exception).__name__}: {exception.args[0]}"
self.error_code = "E902"
self.line_number = 1
self.column_number = 0

View file

@ -369,6 +369,4 @@ def get_local_plugins(config_finder):
return local_plugins
LocalPlugins = collections.namedtuple(
"LocalPlugins", "extension report paths"
)
LocalPlugins = collections.namedtuple("LocalPlugins", "extension report paths")

View file

@ -472,8 +472,7 @@ class Checkers(PluginTypeManager):
plugin.to_dictionary() for plugin in self.logical_line_plugins
],
"physical_line_plugins": [
plugin.to_dictionary()
for plugin in self.physical_line_plugins
plugin.to_dictionary() for plugin in self.physical_line_plugins
],
}

View file

@ -289,9 +289,7 @@ class FileProcessor:
except (tokenize.TokenError, SyntaxError) as exc:
raise exceptions.InvalidSyntax(exception=exc)
def _noqa_line_range(
self, min_line: int, max_line: int
) -> Dict[int, str]:
def _noqa_line_range(self, min_line: int, max_line: int) -> Dict[int, str]:
line_range = range(min_line, max_line + 1)
joined = "".join(self.lines[min_line - 1 : max_line])
return dict.fromkeys(line_range, joined)

View file

@ -368,9 +368,7 @@ class StyleGuideManager:
:rtype:
:class:`~flake8.style_guide.StyleGuide`
"""
per_file = utils.parse_files_to_codes_mapping(
options.per_file_ignores
)
per_file = utils.parse_files_to_codes_mapping(options.per_file_ignores)
for filename, violations in per_file:
yield self.default_style_guide.copy(
filename=filename, extend_ignore_with=violations
@ -579,11 +577,7 @@ class StyleGuide:
)
is_not_inline_ignored = error.is_inline_ignored(disable_noqa) is False
is_included_in_diff = error.is_in(self._parsed_diff)
if (
error_is_selected
and is_not_inline_ignored
and is_included_in_diff
):
if error_is_selected and is_not_inline_ignored and is_included_in_diff:
self.formatter.handle(error)
self.stats.record(error)
return 1

View file

@ -271,13 +271,10 @@ def parse_unified_diff(diff: Optional[str] = None) -> Dict[str, Set[int]]:
# comparing.
if hunk_match:
(row, number_of_rows) = [
1 if not group else int(group)
for group in hunk_match.groups()
1 if not group else int(group) for group in hunk_match.groups()
]
assert current_path is not None
parsed_paths[current_path].update(
range(row, row + number_of_rows)
)
parsed_paths[current_path].update(range(row, row + number_of_rows))
# We have now parsed our diff into a dictionary that looks like:
# {'file.py': set(range(10, 16), range(18, 20)), ...}