Skip to content

Pyreverse: Aggregation/compostion doesn't work across modules. #9271

@bMorgan01

Description

@bMorgan01

Bug description

I have a project with this structure:

pyreverse_test
     __init__.py
     a.py
     b.py

a.py contains:

class A:
    def __init__(self) -> None:
        self.var = 2

b.py contains:

from a import A

class B:
    def __init__(self) -> None:
        self.a_obj: A = A()

Running pyreverse yields this result:
classes0

Configuration

No response

Command used

Working directory: pyreverse_test

pyreverse . -f ALL -o png

Pylint output

Format png is not supported natively. Pyreverse will try to generate it using Graphviz...
Analysed 3 modules with a total of 1 imports

Expected behavior

I expect the result to match this, un-separated, code.

class A:
    def __init__(self) -> None:
        self.var = 2

class B:
    def __init__(self) -> None:
        self.a_obj: A = A()

Which is this:
classes

Pylint version

pylint 3.0.2
astroid 3.0.1
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]

OS / Environment

Windows 10 / powershell

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions