Trying to deal with circular dependencies using dependency inversion in Python

407 Views Asked by At

Here's a simple diagram that illustrates the problem

Description: there is a Pipeline entity that contains a Source entity, the Source is validated using the SourceValidator, and it in turn, in order to validate the source, must create a test pipeline, which can be created using the PipelineManager. Thus, there is a circular dependency of two packages on each other.

In a statically typed language I would create an interface on which the SourceValidator will depend, and in the pipeline package I would implement it and inject a specific instance into the SourceValidator using a Dependency Injection Container

But as I know this is not a pythonic way to use dependency injection containers, so could please someone help to understand what will be the pythonic way of dealing with this problem?

0

There are 0 best solutions below