diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2015-10-30 14:51:33 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2015-10-30 14:51:33 +0200 |
commit | 247dc3c46a24920b40afd1272671a69287e27b1a (patch) | |
tree | 33fbb6eeeaa51669bf40ac04af3cbc4ca1f9bccf | |
parent | a335a4d1cf35aa1ab04c94a73d1f19183ab04f96 (diff) | |
download | pylint-247dc3c46a24920b40afd1272671a69287e27b1a.tar.gz |
Separe the conditions to improve the readability of the code.
-rw-r--r-- | pylint/checkers/classes.py | 4 |
1 files changed, 4 insertions, 0 deletions
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()): |