summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2016-10-25 12:02:00 -0500
committerIan Cordasco <graffatcolmingov@gmail.com>2016-10-25 12:02:00 -0500
commit8dfe38e9e6541185e78a25d684ca1a4a4d9695b0 (patch)
tree5278926067a9782eb5f4cde88ae5ed14d6bff074 /src
parent1cfc12f366c8b3408993374ddc5a73f5f66da43e (diff)
downloadflake8-8dfe38e9e6541185e78a25d684ca1a4a4d9695b0.tar.gz
Fix up FileProcessor.file_tokens property
We opted to not copy the file_tokens attribute each time it's accessed in the merge request discussion but it was never reflected in the code. Further, the attribute had no documentation or docstring, so we've added that. Finally, we address a personal style nit that I otherwise wouldn't have picked at.
Diffstat (limited to 'src')
-rw-r--r--src/flake8/processor.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/flake8/processor.py b/src/flake8/processor.py
index 0e8c153..8490092 100644
--- a/src/flake8/processor.py
+++ b/src/flake8/processor.py
@@ -103,15 +103,22 @@ class FileProcessor(object):
@property
def file_tokens(self):
+ """The complete set of tokens for a file.
+
+ Accessing this attribute *may* raise an InvalidSyntax exception.
+
+ :raises: flake8.exceptions.InvalidSyntax
+ """
if self._file_tokens is None:
line_iter = iter(self.lines)
try:
self._file_tokens = list(tokenize.generate_tokens(
- lambda: next(line_iter)))
+ lambda: next(line_iter)
+ ))
except tokenize.TokenError as exc:
raise exceptions.InvalidSyntax(exc.message, exception=exc)
- return self._file_tokens[:]
+ return self._file_tokens
@contextlib.contextmanager
def inside_multiline(self, line_number):