localvectordb.utils module
- localvectordb.utils.resolve_env_ref(value: str | None, *, what: str = 'value') str | None
Resolve a
$ENV_VARreference to its environment value.Credentials may be passed as a literal string or as a
$NAMEreference (all-uppercase) to be read from the environment. If a reference is given but the variable is unset, raise a clear error naming the variable rather than silently returningNone(which surfaces later as a confusing “key required” failure). Non-reference values are returned unchanged.
- localvectordb.utils.parse_iso8601(s: str | datetime) datetime
Parse an ISO 8601 datetime string with automatic Z suffix handling.
This function centralizes datetime parsing logic to handle the common case where ISO 8601 strings end with ‘Z’ (UTC timezone), which datetime.fromisoformat() cannot parse directly.
- Parameters:
s (Union[str, datetime]) – ISO 8601 datetime string or datetime object. If already a datetime, returns it unchanged.
- Returns:
Parsed datetime object with timezone information preserved.
- Return type:
datetime
- Raises:
ValueError – If the string cannot be parsed as a valid datetime.
Examples
>>> parse_iso8601("2023-12-01T10:30:00Z") datetime.datetime(2023, 12, 1, 10, 30, tzinfo=datetime.timezone.utc)
>>> parse_iso8601("2023-12-01T10:30:00+00:00") datetime.datetime(2023, 12, 1, 10, 30, tzinfo=datetime.timezone.utc)
>>> parse_iso8601("2023-12-01T10:30:00") datetime.datetime(2023, 12, 1, 10, 30)