Skip to content

attribute_model

Classes:

Name Description
AttributeModel

Classes#

AttributeModel #

Bases: BaseModel

Methods:

Name Description
validate_all_ascii

Attributes:

Name Type Description
model_config

Attributes#

model_config class-attribute instance-attribute #
model_config = ConfigDict(extra='allow')

Methods:#

validate_all_ascii #
validate_all_ascii() -> Self
Source code in tsdat/config/attributes/attribute_model.py
@model_validator(mode="after")
def validate_all_ascii(self) -> Self:
    all_values = self.model_dump()
    for key, value in all_values.items():
        if not isinstance(key, str) or not key.isascii():
            raise ValueError(f"'{key}' contains a non-ascii character.")
        if isinstance(value, str) and not value.isascii():
            raise ValueError(
                f"attr '{key}' -> '{value}' contains a non-ascii character."
            )
    return self