pylint
pylint copied to clipboard
Support for complex type annotations in `pyreverse`
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 | Noneshould result in a composition arrow with multiplicity0..1List[X](or any other iterable type) should result in a composition arrow with multiplicity0..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.
CC @qequ to solve this
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?
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 😄
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! 😄