mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-07-13 17:42:20 +03:00
Fix typing issues in some other places
This commit is contained in:
parent
8add4ddf2e
commit
b007d3483b
|
@ -106,7 +106,7 @@ Key features of the ``Dependency Injector``:
|
||||||
|
|
||||||
|
|
||||||
@inject
|
@inject
|
||||||
def main(service: Service = Provide[Container.service]):
|
def main(service: Service = Provide[Container.service]) -> None:
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,18 +3,18 @@ import os
|
||||||
|
|
||||||
class ApiClient:
|
class ApiClient:
|
||||||
|
|
||||||
def __init__(self, api_key: str, timeout: int):
|
def __init__(self, api_key: str, timeout: int) -> None:
|
||||||
self.api_key = api_key # <-- dependency is injected
|
self.api_key = api_key # <-- dependency is injected
|
||||||
self.timeout = timeout # <-- dependency is injected
|
self.timeout = timeout # <-- dependency is injected
|
||||||
|
|
||||||
|
|
||||||
class Service:
|
class Service:
|
||||||
|
|
||||||
def __init__(self, api_client: ApiClient):
|
def __init__(self, api_client: ApiClient) -> None:
|
||||||
self.api_client = api_client # <-- dependency is injected
|
self.api_client = api_client # <-- dependency is injected
|
||||||
|
|
||||||
|
|
||||||
def main(service: Service): # <-- dependency is injected
|
def main(service: Service) -> None: # <-- dependency is injected
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ if __name__ == "__main__":
|
||||||
service=Service(
|
service=Service(
|
||||||
api_client=ApiClient(
|
api_client=ApiClient(
|
||||||
api_key=os.getenv("API_KEY"),
|
api_key=os.getenv("API_KEY"),
|
||||||
timeout=os.getenv("TIMEOUT"),
|
timeout=int(os.getenv("TIMEOUT")),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,7 +23,7 @@ class Container(containers.DeclarativeContainer):
|
||||||
|
|
||||||
|
|
||||||
@inject
|
@inject
|
||||||
def main(service: Service = Provide[Container.service]):
|
def main(service: Service = Provide[Container.service]) -> None:
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user