Skip to content

Commit

Permalink
Pyreverse - Show class has-a relationships inferred from type-hints
Browse files Browse the repository at this point in the history
  • Loading branch information
mbyrnepr2 committed Jul 25, 2021
1 parent a054796 commit 846415d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Expand Up @@ -14,6 +14,10 @@ What's New in Pylint 2.9.6?
===========================
Release date: TBA

* pyreverse: Show class has-a relationships inferred from the type-hint

Closes #4744

..
Put bug fixes that should not wait for a new minor version here

Expand Down
2 changes: 2 additions & 0 deletions doc/whatsnew/2.10.rst
Expand Up @@ -17,4 +17,6 @@ New checkers
Other Changes
=============

* Pyreverse - Show class has-a relationships inferred from type-hints

* Added ``time.clock`` to deprecated functions/methods for python 3.3
6 changes: 3 additions & 3 deletions pylint/pyreverse/utils.py
Expand Up @@ -269,9 +269,9 @@ def infer_node(node: Union[astroid.AssignAttr, astroid.AssignName]) -> set:
otherwise return a set of the inferred types using the NodeNG.infer method"""

ann = get_annotation(node)
if ann:
return {ann}
try:
if ann:
return set(ann.infer())
return set(node.infer())
except astroid.InferenceError:
return set()
return {ann} if ann else set()

0 comments on commit 846415d

Please sign in to comment.