Skip to content

Broken order of complex inheritance #884

Closed
@wb7777

Description

@wb7777

Hello everyone.
In version 4.46.0 the order of complex inheritance has been broken.

from dependency_injector import containers, providers, __version__
from dependency_injector.wiring import Provide, inject


class GrandBase:
    @inject
    def __init__(self, *args, service=Provide['service'], **kwargs):
        print('GrandBase')

        super().__init__()


class Base1(GrandBase):
    ...


class Base2(GrandBase):
    def __init__(self, *args, **kwargs):
        print('Base2')

        super().__init__(*args, **kwargs)


class SubClass(Base1, Base2):
    ...


class Container(containers.DeclarativeContainer):
    service = providers.Object('service')


container = Container()

container.wire(modules=[__name__])

print(f"dependency_injector: {__version__}")

SubClass()

In version 4.45.0:

dependency_injector: 4.45.0
Base2
GrandBase

In version 4.46.0:

dependency_injector: 4.46.0
GrandBase

Activity

added theissue type on May 28, 2025
linked a pull request that will close this issueDo not override methods without patching #886on May 28, 2025
ZipFile

ZipFile commented on May 28, 2025

@ZipFile
Contributor

Fixed in v4.47.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @ZipFile@wb7777

      Issue actions

        Broken order of complex inheritance · Issue #884 · ets-labs/python-dependency-injector