TATTL is a library that deserializes arbitrary data and validates that it conforms to a type
structure you define. It will either return an instance of a dataclass
that you give it, or it
will throw an exception indicating that the data's types don't fit. TATTL supports nesting and
modern type annotations.
Install TATTL with your favourite Python package manager. We recommend
uv
, but pip
works too.
pip install tattl
uv add tattl
TATTL will take some TOML-structured data and transform it into an instance of a dataclass while validating type annotations. As a basic example:
import tattl
import tomllib
from dataclasses import dataclass
data = """
foo = "Hello, world!"
bar = 3.14
"""
@dataclass
class Structure:
foo: str
bar: float
loaded_data = tattl.unpack_dict(
tomllib.loads(data),
Structure
)
For advanced usage and an API reference, see the documentation.
This work is available under the terms of the BSD 3-Clause License.