Fix missing attributes for pep8 plugins

This commit is contained in:
Ian Cordasco 2016-03-10 19:54:53 -06:00
parent f04d8da485
commit 960f4d6af7
2 changed files with 16 additions and 1 deletions

View file

@ -232,6 +232,7 @@ class FileChecker(object):
LOG.debug('Logical line: "%s"', logical_line.rstrip())
for plugin in self.checks.logical_line_plugins:
self.processor.update_checker_state_for(plugin)
results = self.run_check(plugin, logical_line=logical_line) or ()
for offset, text in results:
offset = find_offset(offset, mapping)
@ -248,6 +249,7 @@ class FileChecker(object):
def run_physical_checks(self, physical_line):
"""Run all checks for a given physical line."""
for plugin in self.checks.physical_line_plugins:
self.processor.update_checker_state_for(plugin)
result = self.run_check(plugin, physical_line=physical_line)
if result is not None:
column_offset, text = result

View file

@ -57,6 +57,12 @@ class FileProcessor(object):
self.blank_before = 0
#: Number of blank lines
self.blank_lines = 0
#: Checker states for each plugin?
self._checker_states = {}
#: Current checker state
self.checker_state = None
#: User provided option for hang closing
self.hang_closing = options.hang_closing
#: Character used for indentation
self.indent_char = None
#: Current level of indentation
@ -80,7 +86,7 @@ class FileProcessor(object):
#: Total number of lines in the file
self.total_lines = len(self.lines)
#: Verbosity level of Flake8
self.verbosity = options.verbose
self.verbose = options.verbose
@contextlib.contextmanager
def inside_multiline(self, line_number):
@ -110,6 +116,13 @@ class FileProcessor(object):
if self.blank_before < self.blank_lines:
self.blank_before = self.blank_lines
def update_checker_state_for(self, plugin):
"""Update the checker_state attribute for the plugin."""
if 'checker_state' in plugin.parameters:
self.checker_state = self._checker_states.setdefault(
plugin.name, {}
)
def next_logical_line(self):
"""Record the previous logical line.