Registry / serialization / datafiles

datafiles

JSON →
library2.5pypypi✓ verified 34d ago

A file-based ORM for Python dataclasses that stores objects in YAML, JSON, or TOML files. Current version: 2.5. Release cadence: irregular, latest in 2023.

serializationdatabase
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

datafiles uses decorators, not direct import of a class named datafile.

import datafiles

The decorator is in the datafiles package.

from datafiles import datafile

Define a dataclass decorated with @datafile to map its instances to a YAML file.

from dataclasses import dataclass from datafiles import datafile @datafile("data/{self.name}.yml") class Person: name: str age: int = 0 p = Person("Alice") p.age = 30 print(p.age) # 30
Debug
Known footguns
breakingIn version 2.0, the storage directory structure changed. Files are now saved by default under the 'data' subdirectory relative to the working directory, not the module's directory.
deprecatedSupport for TOML format requires the `toml` library, which is not installed by default. Install with `pip install datafiles[toml]`.
gotchaFile patterns can be ambiguous. If multiple objects map to the same file, they will overwrite each other. Use unique patterns per class.
gotchaChanging a field name after data has been stored will break deserialization because the file format uses field names as keys.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources