I am having trouble generating UMLs with pyreverse, in particular with composition relationships when classes are not part of the same module, and when using absolute imports.
To illustrate the problem, I have the following two modules a.py and b.py in the same package:
a.py:
from b import B
class A:
def __init__(self, b):
self.b: B = b
b.py:
class B:
pass
When I run a pyreverse command in a terminal from the package, I get the following UML. It does not show the composition relationship between the two classes A and B:
However, when I do a relative import from .b import B in a.py, I get the expected result:
It seems like pyreverse does not recognize in the first case that classes B are the same. To resolve the problem, I have tried to add the absolute path of the package to the environment variable PYTHONPATH. However, this did not resolve the problem.
Does anybody know how I can make pyreverse generate the right relationships in the UMLs when classes are defined in different modules, and when using absolute imports?
I am using python 3.8.8 and pylint version 2.12.2.



