diff options
author | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2014-07-25 13:07:34 +0200 |
---|---|---|
committer | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2014-07-25 13:07:34 +0200 |
commit | 4449a950ea759331f0840435616be7591fa407a0 (patch) | |
tree | ed2da8e392fe050bea52f169ed3084df53337193 /checkers/classes.py | |
parent | ee26e69c938d62c3fc48cd6848bee35ccce70637 (diff) | |
download | pylint-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.py | 10 |
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 |