diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2014-10-23 01:03:41 +0300 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2014-10-23 01:03:41 +0300 |
commit | e14e84e92c838593d39249577d5a2077658e57bc (patch) | |
tree | b889a3865109191848f7207a434c52bc7bec8fa4 /checkers/format.py | |
parent | 9dfe752a8debb5a4cadb647d18f215807546db0f (diff) | |
download | pylint-git-e14e84e92c838593d39249577d5a2077658e57bc.tar.gz |
'too-many-lines' disable pragma can be located on any line, not only the first.
Closes issue #321.
Diffstat (limited to 'checkers/format.py')
-rw-r--r-- | checkers/format.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/checkers/format.py b/checkers/format.py index db04a5f45..813130bae 100644 --- a/checkers/format.py +++ b/checkers/format.py @@ -26,7 +26,7 @@ import sys import tokenize from functools import reduce import six -from six.moves import zip +from six.moves import zip, map, filter from astroid import nodes @@ -789,7 +789,15 @@ class FormatChecker(BaseTokenChecker): line_num -= 1 # to be ok with "wc -l" if line_num > self.config.max_module_lines: - self.add_message('too-many-lines', args=(line_num, self.config.max_module_lines), line=1) + # Get the line where the too-many-lines (or its message id) + # was disabled or default to 1. + symbol = self.linter.msgs_store.check_message_id('too-many-lines') + names = (symbol.msgid, 'too-many-lines') + line = next(filter(None, + map(self.linter._pragma_lineno.get, names)), 1) + self.add_message('too-many-lines', + args=(line_num, self.config.max_module_lines), + line=line) def _check_line_ending(self, line_ending, line_num): # check if line endings are mixed |