From 074739de276283fea9a574e08db82e404ddf4fc4 Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Sat, 27 Feb 2016 00:06:19 -0600 Subject: [PATCH] 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. --- flake8/checker.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/flake8/checker.py b/flake8/checker.py index bf72362..9f2154d 100644 --- a/flake8/checker.py +++ b/flake8/checker.py @@ -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)