Constants and Exceptions¶
These two modules sit at Layer 0 — they have zero internal dependencies and form the foundation that every other module builds on.
Constants — sayt2.constants¶
Three str-based enums define the valid values for field configuration.
Using enums (rather than bare strings) gives IDE autocomplete and catches typos
at validation time.
class FieldTypeEnum(str, enum.Enum):
STORED = "stored"
KEYWORD = "keyword"
TEXT = "text"
NGRAM = "ngram"
NUMERIC = "numeric"
DATETIME = "datetime"
BOOLEAN = "boolean"
FieldTypeEnum lists the seven field types. Each
value matches the type discriminator on the corresponding
BaseField subclass.
class TokenizerEnum(str, enum.Enum):
DEFAULT = "default"
EN_STEM = "en_stem"
TokenizerEnum enumerates the built-in tokenisers
available for TextField.
class NumericKindEnum(str, enum.Enum):
I64 = "i64"
U64 = "u64"
F64 = "f64"
NumericKindEnum specifies the numeric precision for
NumericField — signed 64-bit integer, unsigned 64-bit
integer, or 64-bit float.
Exceptions — sayt2.exc¶
Three custom exceptions provide clear, catchable error signals.
class MalformedFieldSettingError(ValueError):
"""Raised when a field configuration is invalid."""
pass
class MalformedDatasetSettingError(ValueError):
"""Raised when a DataSet configuration is invalid (e.g. duplicate field names)."""
pass
class TrackerIsLockedError(RuntimeError):
"""Raised when attempting to acquire a lock that is already held and not expired."""
pass