Skip to content

Commit d176f0a

Browse files
committed
fix(mypy): fix resolve_truthy_env_var_choice env typing
`env` is actually a required value otherwise strtobool would fail
1 parent 0027d1b commit d176f0a

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

aws_lambda_powertools/event_handler/api_gateway.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def __init__(
274274
self._cors_enabled: bool = cors is not None
275275
self._cors_methods: Set[str] = {"OPTIONS"}
276276
self._debug = resolve_truthy_env_var_choice(
277-
choice=debug, env=os.getenv(constants.EVENT_HANDLER_DEBUG_ENV, "false")
277+
env=os.getenv(constants.EVENT_HANDLER_DEBUG_ENV, "false"), choice=debug
278278
)
279279

280280
def get(self, rule: str, cors: Optional[bool] = None, compress: bool = False, cache_control: Optional[str] = None):

aws_lambda_powertools/logging/logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def handler(event, context):
324324
)
325325

326326
log_event = resolve_truthy_env_var_choice(
327-
choice=log_event, env=os.getenv(constants.LOGGER_LOG_EVENT_ENV, "false")
327+
env=os.getenv(constants.LOGGER_LOG_EVENT_ENV, "false"), choice=log_event
328328
)
329329

330330
@functools.wraps(lambda_handler)

aws_lambda_powertools/middleware_factory/factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def lambda_handler(event, context):
106106
return functools.partial(lambda_handler_decorator, trace_execution=trace_execution)
107107

108108
trace_execution = resolve_truthy_env_var_choice(
109-
choice=trace_execution, env=os.getenv(constants.MIDDLEWARE_FACTORY_TRACE_ENV, "false")
109+
env=os.getenv(constants.MIDDLEWARE_FACTORY_TRACE_ENV, "false"), choice=trace_execution
110110
)
111111

112112
@functools.wraps(decorator)

aws_lambda_powertools/shared/functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
from typing import Any, Optional, Union
33

44

5-
def resolve_truthy_env_var_choice(env: Optional[Any] = None, choice: Optional[bool] = None) -> bool:
5+
def resolve_truthy_env_var_choice(env: str, choice: Optional[bool] = None) -> bool:
66
"""Pick explicit choice over truthy env value, if available, otherwise return truthy env value
77
88
NOTE: Environment variable should be resolved by the caller.
99
1010
Parameters
1111
----------
12-
env : Any, Optional
12+
env : str
1313
environment variable actual value
1414
choice : bool
1515
explicit choice

0 commit comments

Comments
 (0)