Skip to content

Commit 68ce01b

Browse files
committed
add back type checkers
1 parent 708fd8b commit 68ce01b

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

sqlmesh/core/config/root.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,30 @@
4444
from sqlmesh.core.user import User
4545
from sqlmesh.utils.date import to_timestamp, now
4646
from sqlmesh.utils.errors import ConfigError
47-
from sqlmesh.utils.pydantic import model_validator, field_validator
47+
from sqlmesh.utils.pydantic import model_validator
48+
49+
50+
def validate_no_past_ttl(v: str) -> str:
51+
current_time = now()
52+
if to_timestamp(v, relative_base=current_time) < to_timestamp(current_time):
53+
raise ValueError(
54+
f"TTL '{v}' is in the past. Please specify a relative time in the future. Ex: `in 1 week` instead of `1 week`."
55+
)
56+
return v
57+
58+
59+
def gateways_ensure_dict(value: t.Dict[str, t.Any]) -> t.Dict[str, t.Any]:
60+
try:
61+
if not isinstance(value, GatewayConfig):
62+
GatewayConfig.parse_obj(value)
63+
return {"": value}
64+
except Exception:
65+
return value
66+
67+
68+
def validate_regex_key_dict(value: t.Dict[str | re.Pattern, t.Any]) -> t.Dict[re.Pattern, t.Any]:
69+
return compile_regex_mapping(value)
70+
4871

4972

5073
def validate_no_past_ttl(v: str) -> str:

0 commit comments

Comments
 (0)