Skip to content

Commit

Permalink
Update single and multiple containers example
Browse files Browse the repository at this point in the history
  • Loading branch information
rmk135 committed Sep 29, 2021
1 parent 1aa2be4 commit 35864f4
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .containers import Application


if __name__ == '__main__':
if __name__ == "__main__":
application = Application()
config = application.service.config()
config.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@


class Core(containers.DeclarativeContainer):
config = providers.Configuration('config')
config = providers.Configuration("config")


class Storage(containers.DeclarativeContainer):
queue = providers.Singleton(lambda: 'Some storage')
queue = providers.Singleton(lambda: "Some storage")


class Adapter(containers.DeclarativeContainer):
core = providers.DependenciesContainer(config=providers.Configuration())
tinydb = providers.Singleton(
lambda db_path: f'DB Path=[{db_path}]',
lambda db_path: f"DB Path=[{db_path}]",
db_path=core.config.default.db_path,
)

Expand All @@ -25,7 +25,7 @@ class Repository(containers.DeclarativeContainer):
adapter = providers.DependenciesContainer()
storage = providers.DependenciesContainer()
site = providers.Singleton(
lambda adapter, queue: f'Adapter=[{adapter}], queue=[{queue}]',
lambda adapter, queue: f"Adapter=[{adapter}], queue=[{queue}]",
adapter=adapter.tinydb,
queue=storage.queue,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ def __init__(self, config):
self._config = config

def build(self):
self._config.from_dict({'default': {'db_path': '~/test'}})
self._config.from_dict({"default": {"db_path": "~/test"}})
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys

from dependency_injector.wiring import inject, Provide
from dependency_injector.wiring import Provide, inject

from .services import UserService, AuthService, PhotoService
from .containers import Application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys

from dependency_injector.wiring import inject, Provide
from dependency_injector.wiring import Provide, inject

from .services import UserService, AuthService, PhotoService
from .containers import Container
Expand Down

0 comments on commit 35864f4

Please sign in to comment.