diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2020-03-08 18:15:04 +0100 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2020-03-08 18:15:04 +0100 |
commit | 018e4b669f60dd905c5b86fbe3c963f13c2ce4fa (patch) | |
tree | 7bcf8f48f1fa61cd99fdd00c0a4fe8ef624d34a3 | |
parent | ca87a2c6e181a85cd81a7840e7f1551e511d08db (diff) | |
download | pylint-git-018e4b669f60dd905c5b86fbe3c963f13c2ce4fa.tar.gz |
Correct some types and guard against unexpected values in classes checkers
-rw-r--r-- | pylint/checkers/base.py | 9 | ||||
-rw-r--r-- | pylint/checkers/classes.py | 2 | ||||
-rw-r--r-- | pylint/checkers/utils.py | 2 |
3 files changed, 8 insertions, 5 deletions
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py index 7eb35be0b..22eb9b3b3 100644 --- a/pylint/checkers/base.py +++ b/pylint/checkers/base.py @@ -317,11 +317,10 @@ def _get_properties(config): return property_classes, property_names -def _determine_function_name_type(node, config=None): +def _determine_function_name_type(node: astroid.FunctionDef, config=None): """Determine the name type whose regex the a function's name should match. :param node: A function node. - :type node: astroid.node_classes.NodeNG :param config: Configuration from which to pull additional property classes. :type config: :class:`optparse.Values` @@ -349,7 +348,11 @@ def _determine_function_name_type(node, config=None): and decorator.attrname in property_names ): inferred = utils.safe_infer(decorator) - if inferred and inferred.qname() in property_classes: + if ( + inferred + and hasattr(inferred, "qname") + and inferred.qname() in property_classes + ): return "attr" return "method" diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py index 4f62f1867..af5a0d4e3 100644 --- a/pylint/checkers/classes.py +++ b/pylint/checkers/classes.py @@ -791,7 +791,7 @@ a metaclass class method.", """ for base in node.bases: ancestor = safe_infer(base) - if ancestor in (astroid.Uninferable, None): + if not ancestor: continue if isinstance(ancestor, astroid.Instance) and ancestor.is_subtype_of( "%s.type" % (BUILTINS,) diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index ea67814d7..e7c133933 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -776,7 +776,7 @@ def decorated_with( @lru_cache(maxsize=1024) def unimplemented_abstract_methods( - node: astroid.node_classes.NodeNG, is_abstract_cb: astroid.FunctionDef = None + node: astroid.ClassDef, is_abstract_cb: astroid.FunctionDef = None ) -> Dict[str, astroid.node_classes.NodeNG]: """ Get the unimplemented abstract methods for the given *node*. |