mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-30 02:46:52 +00:00
Accept the StyleGuide instead of options
pep8's checker has the noqa logic which we've correctly placed on the StyleGuide object. By passing the StyleGuide in to our checkers we can have the checkers pass the physical line to the StyleGuide so we can eliminate our usage of linecache.
This commit is contained in:
parent
12e71b0372
commit
074739de27
1 changed files with 11 additions and 10 deletions
|
|
@ -36,13 +36,13 @@ class Manager(object):
|
|||
together and make our output deterministic.
|
||||
"""
|
||||
|
||||
def __init__(self, options, arguments, checker_plugins):
|
||||
def __init__(self, style_guide, arguments, checker_plugins):
|
||||
"""Initialize our Manager instance.
|
||||
|
||||
:param options:
|
||||
The options parsed from config files and CLI.
|
||||
:type options:
|
||||
optparse.Values
|
||||
: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:
|
||||
|
|
@ -51,7 +51,8 @@ class Manager(object):
|
|||
flake8.plugins.manager.Checkers
|
||||
"""
|
||||
self.arguments = arguments
|
||||
self.options = options
|
||||
self.style_guide = style_guide
|
||||
self.options = style_guide.options
|
||||
self.checks = checker_plugins
|
||||
self.jobs = self._job_count()
|
||||
self.process_queue = None
|
||||
|
|
@ -130,7 +131,7 @@ class Manager(object):
|
|||
paths = self.arguments
|
||||
filename_patterns = self.options.filename
|
||||
self.checkers = [
|
||||
FileChecker(filename, self.checks, self.options)
|
||||
FileChecker(filename, self.checks, self.style_guide)
|
||||
for argument in paths
|
||||
for filename in utils.filenames_from(argument,
|
||||
self.is_path_excluded)
|
||||
|
|
@ -167,7 +168,7 @@ class Manager(object):
|
|||
class FileChecker(object):
|
||||
"""Manage running checks for a file and aggregate the results."""
|
||||
|
||||
def __init__(self, filename, checks, options):
|
||||
def __init__(self, filename, checks, style_guide):
|
||||
"""Initialize our file checker.
|
||||
|
||||
:param str filename:
|
||||
|
|
@ -179,13 +180,13 @@ class FileChecker(object):
|
|||
"""
|
||||
self.filename = filename
|
||||
self.checks = checks
|
||||
self.options = options
|
||||
self.style_guide = style_guide
|
||||
self.results = []
|
||||
self.processor = self._make_processor()
|
||||
|
||||
def _make_processor(self):
|
||||
try:
|
||||
return FileProcessor(self.filename, self.options)
|
||||
return FileProcessor(self.filename, self.style_guide.options)
|
||||
except IOError:
|
||||
# If we can not read the file due to an IOError (e.g., the file
|
||||
# does not exist or we do not have the permissions to open it)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue