diff options
Diffstat (limited to 'pylint/checkers')
-rw-r--r-- | pylint/checkers/classes.py | 11 | ||||
-rw-r--r-- | pylint/checkers/typecheck.py | 6 | ||||
-rw-r--r-- | pylint/checkers/utils.py | 11 |
3 files changed, 16 insertions, 12 deletions
diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py index 86ccb19..c65e10c 100644 --- a/pylint/checkers/classes.py +++ b/pylint/checkers/classes.py @@ -34,7 +34,7 @@ from pylint.checkers.utils import ( overrides_a_method, check_messages, is_attr_private, is_attr_protected, node_frame_class, is_builtin_object, decorated_with_property, unimplemented_abstract_methods, - decorated_with) + decorated_with, class_is_abstract) from pylint.utils import deprecated_option, get_global_option import six @@ -102,15 +102,6 @@ def _called_in_methods(func, klass, methods): return True return False -def class_is_abstract(node): - """return true if the given class node should be considered as an abstract - class - """ - for method in node.methods(): - if method.parent.frame() is node: - if method.is_abstract(pass_is_abstract=False): - return True - return False def _is_attribute_property(name, klass): """ Check if the given attribute *name* is a property diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py index 35b18fb..7baaaf6 100644 --- a/pylint/checkers/typecheck.py +++ b/pylint/checkers/typecheck.py @@ -35,7 +35,7 @@ from pylint.interfaces import IAstroidChecker, INFERENCE, INFERENCE_FAILURE from pylint.checkers import BaseChecker from pylint.checkers.utils import ( is_super, check_messages, decorated_with_property, - decorated_with, node_ignores_exception) + decorated_with, node_ignores_exception, class_is_abstract) from pylint import utils @@ -116,12 +116,14 @@ def _is_abstract_class_name(name): lname = name.lower() is_mixin = lname.endswith('mixin') is_abstract = lname.startswith('abstract') - is_base = lname.startswith('base') + is_base = lname.startswith('base') or lname.endswith('base') return is_mixin or is_abstract or is_base def _is_inside_abstract_class(node): while node is not None: if isinstance(node, astroid.ClassDef): + if class_is_abstract(node): + return True name = getattr(node, 'name', None) if name is not None and _is_abstract_class_name(name): return True diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index 443e32d..8873d0e 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -573,6 +573,17 @@ def node_ignores_exception(node, exception): return False +def class_is_abstract(node): + """return true if the given class node should be considered as an abstract + class + """ + for method in node.methods(): + if method.parent.frame() is node: + if method.is_abstract(pass_is_abstract=False): + return True + return False + + # TODO(cpopa): deprecate these or leave them as aliases? safe_infer = astroid.helpers.safe_infer has_known_bases = astroid.helpers.has_known_bases |