summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2016-11-09 02:31:15 +0000
committerIan Cordasco <graffatcolmingov@gmail.com>2016-11-09 02:31:15 +0000
commit35a35c2a617ac346790180783c616b692d79c03b (patch)
tree2df7d109d478dae00af70d4eb98846139f29a251
parent9334ca9834043e8ac0a2647798382257f4a2470e (diff)
parent6595d3a08dedec4ff07683bf2c8f5aca2637fc5f (diff)
downloadflake8-35a35c2a617ac346790180783c616b692d79c03b.tar.gz
Merge branch 'pycodestyle21' into 'master'
Add previous_unindented_logical_line attribute This attribute is introduced in pycodestyle 2.1.0 Closes #246 See: https://github.com/PyCQA/pycodestyle/issues/400 See merge request !134
-rw-r--r--docs/source/plugin-development/plugin-parameters.rst1
-rw-r--r--src/flake8/processor.py5
2 files changed, 6 insertions, 0 deletions
diff --git a/docs/source/plugin-development/plugin-parameters.rst b/docs/source/plugin-development/plugin-parameters.rst
index 1625098..d387a65 100644
--- a/docs/source/plugin-development/plugin-parameters.rst
+++ b/docs/source/plugin-development/plugin-parameters.rst
@@ -38,6 +38,7 @@ a file, a plugin can ask for any of the following:
- :attr:`~flake8.processor.FileProcessor.noqa`
- :attr:`~flake8.processor.FileProcessor.previous_indent_level`
- :attr:`~flake8.processor.FileProcessor.previous_logical`
+- :attr:`~flake8.processor.FileProcessor.previous_unindented_logical_line`
- :attr:`~flake8.processor.FileProcessor.tokens`
Some properties are set once per file for plugins which iterate itself over
diff --git a/src/flake8/processor.py b/src/flake8/processor.py
index 2757e8f..7cea038 100644
--- a/src/flake8/processor.py
+++ b/src/flake8/processor.py
@@ -41,6 +41,7 @@ class FileProcessor(object):
- :attr:`noqa`
- :attr:`previous_indent_level`
- :attr:`previous_logical`
+ - :attr:`previous_unindented_logical_line`
- :attr:`tokens`
- :attr:`file_tokens`
- :attr:`total_lines`
@@ -89,6 +90,8 @@ class FileProcessor(object):
self.previous_indent_level = 0
#: Previous logical line
self.previous_logical = ''
+ #: Previous unindented (i.e. top-level) logical line
+ self.previous_unindented_logical_line = ''
#: Current set of tokens
self.tokens = []
#: Total number of lines in the file
@@ -163,6 +166,8 @@ class FileProcessor(object):
if self.logical_line:
self.previous_indent_level = self.indent_level
self.previous_logical = self.logical_line
+ if not self.indent_level:
+ self.previous_unindented_logical_line = self.logical_line
self.blank_lines = 0
self.tokens = []
self.noqa = False