Skip to content

Commit

Permalink
Add previous_unindented_logical_line attribute
Browse files Browse the repository at this point in the history
This attribute is introduced in pycodestyle 2.1.0

Closes #246

See: PyCQA/pycodestyle#400
  • Loading branch information
Yen Chi Hsuan committed Nov 8, 2016
1 parent 9553c8d commit 6595d3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/source/plugin-development/plugin-parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/flake8/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -89,6 +90,8 @@ def __init__(self, filename, options, lines=None):
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
Expand Down Expand Up @@ -163,6 +166,8 @@ def next_logical_line(self):
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
Expand Down

0 comments on commit 6595d3a

Please sign in to comment.