From 74f38616b403a634e879205f1550d46d909d7db9 Mon Sep 17 00:00:00 2001 From: Torsten Marek Date: Fri, 29 Mar 2013 18:09:59 +0100 Subject: 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 --- lint.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'lint.py') diff --git a/lint.py b/lint.py index cd571ae..1805692 100644 --- a/lint.py +++ b/lint.py @@ -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 -- cgit v1.2.1