Erick Friis 2023-11-13 14:03:15 -08:00 committed by GitHub
parent b46f88d364
commit 50a5c919f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
import datetime
import warnings
from typing import Any, Literal, Optional, Sequence, Union
from typing_extensions import TypedDict
@ -55,6 +56,8 @@ GRAMMAR = r"""
class ISO8601Date(TypedDict):
"""A date in ISO 8601 format (YYYY-MM-DD)."""
date: str
type: Literal["date"]
@ -140,11 +143,11 @@ class QueryTransformer(Transformer):
item = str(item).strip("\"'")
try:
datetime.datetime.strptime(item, "%Y-%m-%d")
except ValueError as e:
raise ValueError(
except ValueError:
warnings.warn(
"Dates are expected to be provided in ISO 8601 date format "
"(YYYY-MM-DD)."
) from e
)
return {"date": item, "type": "date"}
def string(self, item: Any) -> str: