mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-05 04:36:52 +00:00
refactor run_checks to not take an Optional list of filenames
This commit is contained in:
parent
6e5600f8ec
commit
77a054688b
6 changed files with 18 additions and 22 deletions
|
|
@ -103,7 +103,8 @@ class StyleGuide:
|
|||
:rtype:
|
||||
flake8.api.legacy.Report
|
||||
"""
|
||||
self._application.run_checks(paths)
|
||||
self._application.options.filenames = paths
|
||||
self._application.run_checks()
|
||||
self._application.report_errors()
|
||||
return Report(self._application)
|
||||
|
||||
|
|
|
|||
|
|
@ -56,21 +56,18 @@ class Manager:
|
|||
together and make our output deterministic.
|
||||
"""
|
||||
|
||||
def __init__(self, style_guide, arguments, checker_plugins):
|
||||
def __init__(self, style_guide, checker_plugins):
|
||||
"""Initialize our Manager instance.
|
||||
|
||||
:param style_guide:
|
||||
The instantiated style guide for this instance of Flake8.
|
||||
:type style_guide:
|
||||
flake8.style_guide.StyleGuide
|
||||
:param list arguments:
|
||||
The extra arguments parsed from the CLI (if any)
|
||||
:param checker_plugins:
|
||||
The plugins representing checks parsed from entry-points.
|
||||
:type checker_plugins:
|
||||
flake8.plugins.manager.Checkers
|
||||
"""
|
||||
self.arguments = arguments
|
||||
self.style_guide = style_guide
|
||||
self.options = style_guide.options
|
||||
self.checks = checker_plugins
|
||||
|
|
@ -112,7 +109,7 @@ class Manager:
|
|||
)
|
||||
return 0
|
||||
|
||||
if utils.is_using_stdin(self.arguments):
|
||||
if utils.is_using_stdin(self.options.filenames):
|
||||
LOG.warning(
|
||||
"The --jobs option is not compatible with supplying "
|
||||
"input using - . Ignoring --jobs arguments."
|
||||
|
|
@ -159,7 +156,7 @@ class Manager:
|
|||
def make_checkers(self, paths: Optional[List[str]] = None) -> None:
|
||||
"""Create checkers for each file."""
|
||||
if paths is None:
|
||||
paths = self.arguments
|
||||
paths = self.options.filenames
|
||||
|
||||
checks = self.checks.to_dictionary()
|
||||
self._all_checkers = [
|
||||
|
|
|
|||
|
|
@ -246,28 +246,25 @@ class Application:
|
|||
|
||||
def make_file_checker_manager(self) -> None:
|
||||
"""Initialize our FileChecker Manager."""
|
||||
assert self.options is not None
|
||||
self.file_checker_manager = checker.Manager(
|
||||
style_guide=self.guide,
|
||||
arguments=self.options.filenames,
|
||||
checker_plugins=self.check_plugins,
|
||||
)
|
||||
|
||||
def run_checks(self, files: Optional[List[str]] = None) -> None:
|
||||
def run_checks(self) -> None:
|
||||
"""Run the actual checks with the FileChecker Manager.
|
||||
|
||||
This method encapsulates the logic to make a
|
||||
:class:`~flake8.checker.Manger` instance run the checks it is
|
||||
managing.
|
||||
|
||||
:param list files:
|
||||
List of filenames to process
|
||||
"""
|
||||
assert self.file_checker_manager is not None
|
||||
if self.running_against_diff:
|
||||
files = sorted(self.parsed_diff)
|
||||
files: Optional[List[str]] = sorted(self.parsed_diff)
|
||||
if not files:
|
||||
return
|
||||
else:
|
||||
files = None
|
||||
|
||||
self.file_checker_manager.start(files)
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue