pylint icon indicating copy to clipboard operation
pylint copied to clipboard

Support for complex type annotations in `pyreverse`

Open DudeNr33 opened this issue 3 years ago • 4 comments

Current problem

See this SO question: Currently pyreverse does not show relationships between classes if they are used in complex type hints like Union[X, Y], List[X] or Optional[X].

Desired solution

pyreverse should be able to display relationships also in this cases, ideally with a suitable multiplicity on the arrow. For example:

  • Optional[X] / X | None should result in a composition arrow with multiplicity 0..1
  • List[X] (or any other iterable type) should result in a composition arrow with multiplicity 0..n

The case for Union is up for discussion. As outlined in the linked SO question, there is no straightforward way to display this in a "correct" way without introducing intermediary nodes.

Additional context

For the List[X] case #6434 might bring a solution.

DudeNr33 avatar May 29 '22 10:05 DudeNr33

CC @qequ to solve this

dgutson avatar Oct 27 '22 19:10 dgutson

Hi team, this issue has been inactive over 2 years. Could you please provide an update on whether this feature is still planned for implementation or if it has been deprioritized?

t29mato avatar May 30 '25 05:05 t29mato

Hello @t29mato, pylint is not backed by a team of paid engineers working on it full time and discussing about prioritization behind close door (i.e. let's not put too much emphasis on making the lib easy to use outside our paying saas, fyuknowwhatImean) : all the discussions happen in the bug tracker (github). So if something was happening, you would see it here :)

If someone come up with a merge request proposal we're going to review it and merge it and maybe even promote that person to full time volunteer pyreverse maintainer afterward 😄

Pierre-Sassoulas avatar May 30 '25 10:05 Pierre-Sassoulas

Hey @Pierre-Sassoulas,

Thanks for the response! I totally get it - I'm also involved in OSS in my spare time outside of work, so I know how it goes. I'll dig into the source code and see if I can put together a PR. Even PyCharm (which I'm paying for) doesn't support this feature. I'll reach out to their support team about it! 😄

t29mato avatar May 30 '25 12:05 t29mato