summaryrefslogtreecommitdiff
path: root/checkers/classes.py
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2014-07-25 13:07:34 +0200
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2014-07-25 13:07:34 +0200
commit4449a950ea759331f0840435616be7591fa407a0 (patch)
treeed2da8e392fe050bea52f169ed3084df53337193 /checkers/classes.py
parentee26e69c938d62c3fc48cd6848bee35ccce70637 (diff)
downloadpylint-4449a950ea759331f0840435616be7591fa407a0.tar.gz
Don't emit hidden-method message when the attribute has been monkey-patched,
you're on your own when you do that Closes http://www.logilab.org/ticket/36653
Diffstat (limited to 'checkers/classes.py')
-rw-r--r--checkers/classes.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/checkers/classes.py b/checkers/classes.py
index 570f7ac..6d9b2df 100644
--- a/checkers/classes.py
+++ b/checkers/classes.py
@@ -20,7 +20,7 @@ from __future__ import generators
import sys
import astroid
-from astroid import YES, Instance, are_exclusive, AssAttr
+from astroid import YES, Instance, are_exclusive, AssAttr, Class
from astroid.bases import Generator
from pylint.interfaces import IAstroidChecker
@@ -341,8 +341,12 @@ a metaclass class method.'}
# check if the method is hidden by an attribute
try:
overridden = klass.instance_attr(node.name)[0] # XXX
- args = (overridden.root().name, overridden.fromlineno)
- self.add_message('method-hidden', args=args, node=node)
+ overridden_frame = overridden.frame()
+ if overridden_frame.type == 'method':
+ overridden_frame = overridden_frame.parent.frame()
+ if isinstance(overridden_frame, Class) and klass._is_subtype_of(overridden_frame.qname()):
+ args = (overridden.root().name, overridden.fromlineno)
+ self.add_message('method-hidden', args=args, node=node)
except astroid.NotFoundError:
pass