Skip to content

Commit 6595d3a

Browse files
committed
Add previous_unindented_logical_line attribute
This attribute is introduced in pycodestyle 2.1.0 Closes #246 See: PyCQA/pycodestyle#400
1 parent 9553c8d commit 6595d3a

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

docs/source/plugin-development/plugin-parameters.rst

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ a file, a plugin can ask for any of the following:
3838
- :attr:`~flake8.processor.FileProcessor.noqa`
3939
- :attr:`~flake8.processor.FileProcessor.previous_indent_level`
4040
- :attr:`~flake8.processor.FileProcessor.previous_logical`
41+
- :attr:`~flake8.processor.FileProcessor.previous_unindented_logical_line`
4142
- :attr:`~flake8.processor.FileProcessor.tokens`
4243

4344
Some properties are set once per file for plugins which iterate itself over

src/flake8/processor.py

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class FileProcessor(object):
4141
- :attr:`noqa`
4242
- :attr:`previous_indent_level`
4343
- :attr:`previous_logical`
44+
- :attr:`previous_unindented_logical_line`
4445
- :attr:`tokens`
4546
- :attr:`file_tokens`
4647
- :attr:`total_lines`
@@ -89,6 +90,8 @@ def __init__(self, filename, options, lines=None):
8990
self.previous_indent_level = 0
9091
#: Previous logical line
9192
self.previous_logical = ''
93+
#: Previous unindented (i.e. top-level) logical line
94+
self.previous_unindented_logical_line = ''
9295
#: Current set of tokens
9396
self.tokens = []
9497
#: Total number of lines in the file
@@ -163,6 +166,8 @@ def next_logical_line(self):
163166
if self.logical_line:
164167
self.previous_indent_level = self.indent_level
165168
self.previous_logical = self.logical_line
169+
if not self.indent_level:
170+
self.previous_unindented_logical_line = self.logical_line
166171
self.blank_lines = 0
167172
self.tokens = []
168173
self.noqa = False

0 commit comments

Comments
 (0)