summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2011-10-03 10:58:18 +0200
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2011-10-03 10:58:18 +0200
commitdbaa86ab6115358b2c5dc7f751ed37f1f0b5ec47 (patch)
tree7c7c32e7facc56b7b49ff6d498a8e5fac6ab9343
parent41965ed3d6e21115f5dbf3f69e9c741c7471cb70 (diff)
downloadpylint-dbaa86ab6115358b2c5dc7f751ed37f1f0b5ec47.tar.gz
better message for E0202 (closes #77237)
this also ease treatment: don't try to search parent frame (ie belonging class) which may be hazardous, simply use the assignment node.
-rw-r--r--ChangeLog2
-rw-r--r--checkers/classes.py16
-rw-r--r--test/messages/func_e0205.txt2
3 files changed, 10 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index b310c95..fad2984 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,8 @@ ChangeLog for PyLint
* #76920: crash if on eg "pylint --rcfile"(patch by Torsten Marek)
+ * #77237: warning for E0202 may be very misleading
+
2011-07-18 -- 0.24.0
* #69738: add regular expressions support for "generated-members"
diff --git a/checkers/classes.py b/checkers/classes.py
index 6e53ec0..60d20b6 100644
--- a/checkers/classes.py
+++ b/checkers/classes.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2003-2010 LOGILAB S.A. (Paris, FRANCE).
+# Copyright (c) 2003-2011 LOGILAB S.A. (Paris, FRANCE).
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This program is free software; you can redistribute it and/or modify it under
@@ -41,9 +41,10 @@ MSGS = {
compatibility for an unexpected reason. Please report this kind \
if you don\'t make sense of it.'),
- 'E0202': ('An attribute inherited from %s hide this method',
- 'Used when a class defines a method which is hidden by an \
- instance attribute from an ancestor class.'),
+ 'E0202': ('An attribute affected in %s line %s hide this method',
+ 'Used when a class defines a method which is hidden by an '
+ 'instance attribute from an ancestor class or set by some '
+ 'client code.'),
'E0203': ('Access to member %r before its definition line %s',
'Used when an instance member is accessed before it\'s actually\
assigned.'),
@@ -256,11 +257,8 @@ a class method.'}
# check if the method overload an attribute
try:
overridden = klass.instance_attr(node.name)[0] # XXX
- # we may be unable to get owner class if this is a monkey
- # patched method
- while overridden.parent and not isinstance(overridden, astng.Class):
- overridden = overridden.parent.frame()
- self.add_message('E0202', args=overridden.name, node=node)
+ args = (overridden.root().name, overridden.fromlineno)
+ self.add_message('E0202', args=args, node=node)
except astng.NotFoundError:
pass
diff --git a/test/messages/func_e0205.txt b/test/messages/func_e0205.txt
index 1adf408..494f3c3 100644
--- a/test/messages/func_e0205.txt
+++ b/test/messages/func_e0205.txt
@@ -1,2 +1,2 @@
-E: 14:Cdef.abcd: An attribute inherited from Abcd hide this method
+E: 14:Cdef.abcd: An attribute affected in input.func_e0205 line 10 hide this method