Fix a typing issue in an example

`ApiClient` expects timeout to be an integer (based on a type hint), but `os.getenv` returns a string when `TIMEOUT` is set.
This commit is contained in:
Illia Volochii 2022-04-09 16:20:40 +03:00
parent 80cc30523b
commit fcec83779d
No known key found for this signature in database
GPG Key ID: 9BC2D949988CE605

View File

@ -68,7 +68,7 @@ Before:
def __init__(self):
self.api_key = os.getenv("API_KEY") # <-- dependency
self.timeout = os.getenv("TIMEOUT") # <-- dependency
self.timeout = int(os.getenv("TIMEOUT")) # <-- dependency
class Service:
@ -114,7 +114,7 @@ After:
service=Service(
api_client=ApiClient(
api_key=os.getenv("API_KEY"),
timeout=os.getenv("TIMEOUT"),
timeout=int(os.getenv("TIMEOUT")),
),
),
)
@ -137,7 +137,7 @@ Now you need to assemble and inject the objects like this:
service=Service(
api_client=ApiClient(
api_key=os.getenv("API_KEY"),
timeout=os.getenv("TIMEOUT"),
timeout=int(os.getenv("TIMEOUT")),
),
),
)