[Python-modules-commits] [python-flake8] 01/03: Add previous_unindented_logical_line attribute
Ondřej Nový
onovy at moszumanska.debian.org
Tue Nov 8 18:32:57 UTC 2016
This is an automated email from the git hooks/post-receive script.
onovy pushed a commit to branch master
in repository python-flake8.
commit 8280129e7b083f590df8ef8c11cb75739b8553a4
Author: Ondřej Nový <onovy at debian.org>
Date: Tue Nov 8 19:20:15 2016 +0100
Add previous_unindented_logical_line attribute
Origin: https://gitlab.com/pycqa/flake8/merge_requests/134
---
docs/source/plugin-development/plugin-parameters.rst | 1 +
src/flake8/processor.py | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/docs/source/plugin-development/plugin-parameters.rst b/docs/source/plugin-development/plugin-parameters.rst
index fd644bc..c5b5ccb 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 being processed:
diff --git a/src/flake8/processor.py b/src/flake8/processor.py
index 44024e5..b52ef71 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:`total_lines`
- :attr:`verbose`
@@ -88,6 +89,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
@@ -142,6 +145,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
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-flake8.git
More information about the Python-modules-commits
mailing list