diff options
author | Torsten Marek <tmarek@google.com> | 2013-03-29 18:09:59 +0100 |
---|---|---|
committer | Torsten Marek <tmarek@google.com> | 2013-03-29 18:09:59 +0100 |
commit | 74f38616b403a634e879205f1550d46d909d7db9 (patch) | |
tree | c020e72ac9150a8334d715405e4acb6564bb4bf0 /lint.py | |
parent | a22d2cd03aeef02af7ad48c89266fb27bf20f0ac (diff) | |
download | pylint-74f38616b403a634e879205f1550d46d909d7db9.tar.gz |
Make sure that pragmas that apply to whole lines are interpreted literally, so that
their scope is not extended to the whole scope if they occur at the beginning of a
scope.
Closes #123285
Diffstat (limited to 'lint.py')
-rw-r--r-- | lint.py | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -48,7 +48,8 @@ from logilab.astng import MANAGER, nodes, ASTNGBuildingException from logilab.astng.__pkginfo__ import version as astng_version from pylint.utils import (PyLintASTWalker, UnknownMessage, MessagesHandlerMixIn, - ReportsHandlerMixIn, MSG_TYPES, expand_modules) + ReportsHandlerMixIn, MSG_TYPES, expand_modules, + WarningScope) from pylint.interfaces import ILinter, IRawChecker, IASTNGChecker from pylint.checkers import (BaseRawChecker, EmptyReport, table_lines_from_stats) @@ -508,11 +509,16 @@ This is used by the global evaluation report (RP0004).'}), for lineno, state in lines.items(): original_lineno = lineno if first <= lineno <= last: - if lineno > firstchildlineno: - state = True - # set state for all lines for this block - first, last = node.block_range(lineno) - for line in xrange(first, last+1): + # Set state for all lines for this block, if the + # warning is applied to nodes. + if self._messages[msgid].scope == WarningScope.NODE: + if lineno > firstchildlineno: + state = True + first_, last_ = node.block_range(lineno) + else: + first_ = lineno + last_ = last + for line in xrange(first_, last_+1): # do not override existing entries if not line in self._module_msgs_state.get(msgid, ()): if line in lines: # state change in the same block |