Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle has-a relationships for type-hinted arguments in class diagrams #4745

4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
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
Pierre-Sassoulas marked this conversation as resolved.
Show resolved Hide resolved

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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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()