Skip to content
This repository was archived by the owner on Jan 4, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions mws/future_utils/params.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""Parameter manipulation utilities."""

from collections.abc import Iterable, Mapping
from urllib.parse import quote
import datetime
import json
from collections.abc import Iterable, Mapping
from urllib.parse import quote

from dateutil.parser import isoparse

# Removed top-level import to correct circular imports
# (we're in backport territory, these things happen)
Expand Down Expand Up @@ -230,9 +232,19 @@ def clean_value(val):

if isinstance(val, (datetime.datetime, datetime.date)):
return clean_date(val)

if isinstance(val, bool):
return clean_bool(val)

# Detect date strings
try:
parsed_date = isoparse(val)
if len(val) == 10:
return clean_date(parsed_date.date())
return clean_date(parsed_date)
except ValueError:
pass

# For all else, assume a string, and clean that.
return clean_string(str(val))

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
python-dateutil
requests
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
long_description = readme.read()

requires = [
"python-dateutil",
"requests",
]

Expand Down