From 247dc3c46a24920b40afd1272671a69287e27b1a Mon Sep 17 00:00:00 2001 From: Claudiu Popa Date: Fri, 30 Oct 2015 14:51:33 +0200 Subject: Separe the conditions to improve the readability of the code. --- pylint/checkers/classes.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'pylint') diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py index ff4a73c..3d9144d 100644 --- a/pylint/checkers/classes.py +++ b/pylint/checkers/classes.py @@ -634,21 +634,25 @@ a metaclass class method.'} """ if not isinstance(node.value, astroid.Call): return + # check the function called is "classmethod" or "staticmethod" func = node.value.func if (not isinstance(func, astroid.Name) or func.name not in ('classmethod', 'staticmethod')): return + msg = ('no-classmethod-decorator' if func.name == 'classmethod' else 'no-staticmethod-decorator') # assignment must be at a class scope parent_class = node.scope() if not isinstance(parent_class, astroid.ClassDef): return + # Check if the arg passed to classmethod is a class member classmeth_arg = node.value.args[0] if not isinstance(classmeth_arg, astroid.Name): return + method_name = classmeth_arg.name if any(method_name == member.name for member in parent_class.mymethods()): -- cgit v1.2.1