Skip to content

Commit

Permalink
Correct some types and guard against unexpected values in classes che…
Browse files Browse the repository at this point in the history
…ckers
  • Loading branch information
PCManticore committed Mar 8, 2020
1 parent ca87a2c commit 018e4b6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions pylint/checkers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion pylint/checkers/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ def _check_proper_bases(self, node):
"""
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,)
Expand Down
2 changes: 1 addition & 1 deletion pylint/checkers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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*.
Expand Down

0 comments on commit 018e4b6

Please sign in to comment.