New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Dependency is not defined #198
Comments
Hi @j4zzcat , I will do some debugging later today. Roman |
Well, I think that a way to get it working is next: from collections import namedtuple
import dependency_injector.containers as containers
import dependency_injector.providers as providers
app_Config = namedtuple( "Config", [ "dir" ] )
app_ExternalConfigAdapter = namedtuple( "ConfigAdapter", [ "config", "starting_point" ] )
external_RestApiClient = namedtuple( "RestApiClient", [ "config", "version" ] )
class CommonServices( containers.DeclarativeContainer ):
config = providers.Singleton( app_Config, dir = "/root/.qrsa" )
class ExternalServices( containers.DeclarativeContainer ):
version = providers.Dependency()
common_services = providers.DependenciesContainer()
adapted_config = providers.Factory( app_ExternalConfigAdapter,
common_services.config,
"common/nitro"
)
external_rest_client = providers.Singleton( external_RestApiClient,
config = adapted_config,
version = version
)
cs = CommonServices()
qrs = ExternalServices( common_services = cs , version = "9.0" )
qrs.adapted_config()
print(qrs.external_rest_client())
# RestApiClient(config=ConfigAdapter(config=Config(dir='/root/.qrsa'), starting_point='common/nitro'), version='9.0') I will also check the behavior of |
@j4zzcat , I've found an issue, thank you very-very much. It was a really "nasty" bug :) I will publish a fix in few hours or so. |
I wonder why the following code fails?
The text was updated successfully, but these errors were encountered: