Skip to main content

English | 简体中文 | 繁體中文 | 日本語 | Русский

tomlclass

tomlclass

TOML configuration library: a home-grown lossless editing engine plus typed config annotations. Zero third-party dependencies.

Writing a config file back keeps every comment and every bit of formatting intact; declare the structure as Python classes to get a commented template with validation. The configuration semantics come from the ErisPulse framework's config system.

PyPI Python CI License Ruff



Features

  • Lossless editing engine: full-type TOML 1.0 parse and write-back; all 709 toml-test 1.0 cases pass. Untouched documents render byte-identical to input
  • Typed config: declare the schema as classes, docstrings become template comments, validation aggregates all errors, defaults are merged in memory and never written back
  • Comment operations: read, replace and delete comments per key; schema descriptions can be injected as comments (three strategies)
  • tomllib compatible: loads / load follow the stdlib calling convention — migrating costs nothing

Why not tomlkit

tomlkit is the de facto standard for lossless editing, and this project's engine was designed against it as a baseline. Where tomlclass wins:

Dimension tomlkit 0.15 tomlclass 0.1
Parse speed (same machine) baseline 5.8–6.4× faster
Getting a plain dict parse(dumps(doc)) round trip to_dict() builds it directly, zero round trip
Comment operations buried in style objects, no per-key API doc.comment(key) / set_comment as first-class citizens
Schema / template / validation none — assemble it yourself built into Config (template, aggregate validation, env overrides, migration)
Resident memory baseline 0.67×

Source: performance baseline (same machine, same iteration count).

Installation

pip install tomlclass

Usage

Editing a TOML file

import tomlclass

doc = tomlclass.parse(text)
doc["project"]["version"] = "1.0.0"
doc["project"]["dependencies"].append("rich>=13.0")  # spliced in place, comments kept
text = doc.dumps()                                   # only touched lines change

Declarative config

from tomlclass import Config

class Server(Config):
    """
    HTTP server settings.

    host:
        Address to bind.
    port:
        Port to listen on.
    """

    host: str = "127.0.0.1"
    port: int = 8000


server = Server.load("server.toml")  # read + validate + merge defaults
server.port = 9000
server.save("server.toml")           # only changed keys are written

Documentation

  • Engine — Document, editing, tomllib compatibility, errors
  • Annotations — Config, Field, view semantics, env overrides
  • Comments — ownership model, reading and replacing
  • Examples — common scenarios
  • Performance — baseline numbers and measurements
  • Design — layers, semantics, test strategy

Requirements

Python ≥ 3.10, no third-party dependencies.

License

MIT

Metadata

Release files for tomlclass 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tomlclass 0.1.0
File Size Uploaded
tomlclass-0.1.0.tar.gz 270.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tomlclass 0.1.0
File Interpreter ABI Platform
tomlclass-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 301.9 kB

Release files / tomlclass-0.1.0.tar.gz

Download URL tomlclass-0.1.0.tar.gz
Size 270.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4132afdea1f95fbd3c8c18bc5f9fb0d44c59c43a09a2a9fdf910eb3e9113c831
BLAKE2b-256 checksum
How to use checksums
c044fb6b7c00a2b4b1605b231f297827a6be1fc53ac3461f1a93e2a09d7d4fe1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release files / tomlclass-0.1.0-py3-none-any.whl

Download URL tomlclass-0.1.0-py3-none-any.whl
Size 31.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c8afaa26ced8050a5f3f1c361bfab3011b6265235014481a2bdd813c69f52ad
BLAKE2b-256 checksum
How to use checksums
faae8e5000bffbc75111d85c276442fb2c8599df1857cfbe2bc8ad6f09461f36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.1

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page