summaryrefslogtreecommitdiff
path: root/pylint/checkers/classes.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2019-10-30 08:52:23 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2019-10-30 08:52:23 +0100
commit42def1b14d0f93ad284960b26d99639e4a761be4 (patch)
tree4ecc01660edef930ddcf28605387e8e4a4bf9e01 /pylint/checkers/classes.py
parenta25d8df2ac12f040baf73c4ff40fa6b34dc39f97 (diff)
downloadpylint-git-42def1b14d0f93ad284960b26d99639e4a761be4.tar.gz
Return early in visit_class to get rid of a too many branches
Diffstat (limited to 'pylint/checkers/classes.py')
-rw-r--r--pylint/checkers/classes.py31
1 files changed, 17 insertions, 14 deletions
diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py
index 18a9bd22e..146d191ac 100644
--- a/pylint/checkers/classes.py
+++ b/pylint/checkers/classes.py
@@ -952,21 +952,24 @@ a metaclass class method.",
and overridden_frame.type == "method"
):
overridden_frame = overridden_frame.parent.frame()
- if isinstance(overridden_frame, astroid.ClassDef) and klass.is_subtype_of(
- overridden_frame.qname()
+ if not (
+ isinstance(overridden_frame, astroid.ClassDef)
+ and klass.is_subtype_of(overridden_frame.qname())
):
- # If a subclass defined the method then it's not our fault.
- try:
- mro = klass.mro()
- except (InconsistentMroError, DuplicateBasesError):
- pass
- else:
- for subklass in mro[1 : mro.index(overridden_frame) + 1]:
- for obj in subklass.lookup(node.name)[1]:
- if isinstance(obj, astroid.FunctionDef):
- return
- args = (overridden.root().name, overridden.fromlineno)
- self.add_message("method-hidden", args=args, node=node)
+ return
+
+ # If a subclass defined the method then it's not our fault.
+ try:
+ mro = klass.mro()
+ except (InconsistentMroError, DuplicateBasesError):
+ pass
+ else:
+ for subklass in mro[1 : mro.index(overridden_frame) + 1]:
+ for obj in subklass.lookup(node.name)[1]:
+ if isinstance(obj, astroid.FunctionDef):
+ return
+ args = (overridden.root().name, overridden.fromlineno)
+ self.add_message("method-hidden", args=args, node=node)
except astroid.NotFoundError:
pass