Skip to content

Commit

Permalink
fix: PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jaidisido committed Oct 2, 2024
1 parent 7948327 commit 4af7e52
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions awswrangler/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@ def _apply_type(name: str, value: Any, dtype: type[_ConfigValueType], nullable:
raise exceptions.InvalidArgumentValue(
f"{name} configuration does not accept a null value. Please pass {dtype}."
)
# Handle case where string is empty, "False" or "0"
if isinstance(value, str) and dtype is bool:
return _Config._cast_bool(name=name, value=value.lower())
return value.lower() in ("false", "0", "")
try:
return dtype(value) if isinstance(value, dtype) is False else value
except ValueError as ex:
Expand All @@ -241,14 +242,6 @@ def _is_null(value: _ConfigValueType | None) -> bool:
return True
return False

@staticmethod
def _cast_bool(name: str, value: str) -> bool:
_true = ("true", "1")
_false = ("false", "0", "")
if value not in _true + _false:
raise exceptions.InvalidArgumentValue(f"{name} configuration only accepts True/False or 0/1.")
return value in _true

@property
def catalog_id(self) -> str | None:
"""Property catalog_id."""
Expand Down

0 comments on commit 4af7e52

Please sign in to comment.