localvectordb.utils module

localvectordb.utils.resolve_env_ref(value: str | None, *, what: str = 'value') str | None

Resolve a $ENV_VAR reference to its environment value.

Credentials may be passed as a literal string or as a $NAME reference (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 returning None (which surfaces later as a confusing “key required” failure). Non-reference values are returned unchanged.

localvectordb.utils.get_system_version() str
localvectordb.utils.make_filename_safe(name: str, max_length: int = 255) str
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)