Skip to content

Commit 3448d4e

Browse files
committed
Pyreverse - Show class has-a relationships inferred from type-hints
1 parent a054796 commit 3448d4e

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ What's New in Pylint 2.9.6?
1414
===========================
1515
Release date: TBA
1616

17+
* pyreverse: Show class has-a relationships inferred from the type-hint
18+
19+
Closes #4744
20+
1721
..
1822
Put bug fixes that should not wait for a new minor version here
1923

doc/whatsnew/2.10.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ New checkers
1717
Other Changes
1818
=============
1919

20+
* Pyreverse - Show class has-a relationships inferred from type-hints
21+
2022
* Added ``time.clock`` to deprecated functions/methods for python 3.3

pylint/pyreverse/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ def infer_node(node: Union[astroid.AssignAttr, astroid.AssignName]) -> set:
269269
otherwise return a set of the inferred types using the NodeNG.infer method"""
270270

271271
ann = get_annotation(node)
272-
if ann:
273-
return {ann}
274272
try:
273+
if ann:
274+
return set(ann.infer())
275275
return set(node.infer())
276276
except astroid.InferenceError:
277-
return set()
277+
return {ann} if ann else set()

0 commit comments

Comments
 (0)