From f68b59f9ed3fa40e17980a3dff1859076d58c4e5 Mon Sep 17 00:00:00 2001 From: Roman Mogylatov Date: Mon, 20 Dec 2021 15:24:55 +0200 Subject: [PATCH] Update demo example --- README.rst | 6 +++--- docs/index.rst | 6 +++--- docs/introduction/di_in_python.rst | 6 +++--- examples/demo/with_di.py | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index 5dd11a1a..f9be191d 100644 --- a/README.rst +++ b/README.rst @@ -90,7 +90,7 @@ Key features of the ``Dependency Injector``: api_client = providers.Singleton( ApiClient, api_key=config.api_key, - timeout=config.timeout.as_int(), + timeout=config.timeout, ) service = providers.Factory( @@ -106,8 +106,8 @@ Key features of the ``Dependency Injector``: if __name__ == "__main__": container = Container() - container.config.api_key.from_env("API_KEY") - container.config.timeout.from_env("TIMEOUT") + container.config.api_key.from_env("API_KEY", required=True) + container.config.timeout.from_env("TIMEOUT", as_=int, default=5) container.wire(modules=[__name__]) main() # <-- dependency is injected automatically diff --git a/docs/index.rst b/docs/index.rst index afbee51e..6ff500d1 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -96,7 +96,7 @@ Key features of the ``Dependency Injector``: api_client = providers.Singleton( ApiClient, api_key=config.api_key, - timeout=config.timeout.as_int(), + timeout=config.timeout, ) service = providers.Factory( @@ -112,8 +112,8 @@ Key features of the ``Dependency Injector``: if __name__ == "__main__": container = Container() - container.config.api_key.from_env("API_KEY") - container.config.timeout.from_env("TIMEOUT") + container.config.api_key.from_env("API_KEY", required=True) + container.config.timeout.from_env("TIMEOUT", as_=int, default=5) container.wire(modules=[__name__]) main() # <-- dependency is injected automatically diff --git a/docs/introduction/di_in_python.rst b/docs/introduction/di_in_python.rst index 7c1a3cfd..f19a6c26 100644 --- a/docs/introduction/di_in_python.rst +++ b/docs/introduction/di_in_python.rst @@ -172,7 +172,7 @@ the dependency. api_client = providers.Singleton( ApiClient, api_key=config.api_key, - timeout=config.timeout.as_int(), + timeout=config.timeout, ) service = providers.Factory( @@ -188,8 +188,8 @@ the dependency. if __name__ == "__main__": container = Container() - container.config.api_key.from_env("API_KEY") - container.config.timeout.from_env("TIMEOUT") + container.config.api_key.from_env("API_KEY", required=True) + container.config.timeout.from_env("TIMEOUT", as_=int, default=5) container.wire(modules=[__name__]) main() # <-- dependency is injected automatically diff --git a/examples/demo/with_di.py b/examples/demo/with_di.py index 9cb51e16..bf154976 100644 --- a/examples/demo/with_di.py +++ b/examples/demo/with_di.py @@ -13,7 +13,7 @@ class Container(containers.DeclarativeContainer): api_client = providers.Singleton( ApiClient, api_key=config.api_key, - timeout=config.timeout.as_int(), + timeout=config.timeout, ) service = providers.Factory( @@ -29,8 +29,8 @@ def main(service: Service = Provide[Container.service]): if __name__ == "__main__": container = Container() - container.config.api_key.from_env("API_KEY") - container.config.timeout.from_env("TIMEOUT") + container.config.api_key.from_env("API_KEY", required=True) + container.config.timeout.from_env("TIMEOUT", as_=int, default=5) container.wire(modules=[__name__]) main() # <-- dependency is injected automatically