summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flake8/checker.py2
-rw-r--r--flake8/processor.py15
2 files changed, 16 insertions, 1 deletions
diff --git a/flake8/checker.py b/flake8/checker.py
index 675ad0c..9fcaa3c 100644
--- a/flake8/checker.py
+++ b/flake8/checker.py
@@ -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
diff --git a/flake8/processor.py b/flake8/processor.py
index 88514e5..52d7ab1 100644
--- a/flake8/processor.py
+++ b/flake8/processor.py
@@ -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.