Skip to main content

fs-schema

Typed schemas for filesystem layouts. Dataclass-like declarations turn directory contracts into validated, navigable Python values.

uv add "fs-schema[mashumaro,orjson]"
from dataclasses import dataclass

import fs_schema as fss

@dataclass
class Contents:
    title: str

class DataDownload(fss.Schema):
    schema = {
        "packs": {
            fss.FILES: ["upload.log", "request.log"],
            fss.Dir(alias="days", fmt="{day:%Y-%m-%d}"): {
                "parts": fss.File(fmt="{stem}.{ext}", max=4),
            },
        },
        "contents": fss.File("contents.json", schema=Contents),
    }

download = fss.raise_mismatch(DataDownload.bind("."))
with open(download.packs.upload_log, encoding="utf-8") as stream:
    print(stream.read())
part = download.packs.days[-1].parts[-1]
print(part.kwargs.stem, part.path.stat().st_size)
contents: Contents = fss.raise_exn(download.contents.load())
print(contents.title)

Binding validates an existing layout. Templates are collections; indexing selects a concrete match whose parsed captures are available through .args and .kwargs. relative_to() plans output paths without claiming they exist. Format-backed collections plan concrete files or recursively navigable directories; only the top-level plan binds the whole schema. Dataclass schemas use Mashumaro for JSON; install the mashumaro or faster orjson extra.

Expanded quickstart
--8<-- "examples/quickstart.py"
Development
--8<-- "docs/run-help.txt"

API reference · Tutorial · Source · MIT LICENSE

Release files for fs-schema 0.4.5

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

Source distribution (sdist)

Source distribution for fs-schema 0.4.5
File Size Uploaded
fs_schema-0.4.5.tar.gz 51.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fs-schema 0.4.5
File Interpreter ABI Platform
fs_schema-0.4.5-py3-none-any.whl Python 3 none any Details

Total release size: 69.3 kB

Release files / fs_schema-0.4.5.tar.gz

Download URL fs_schema-0.4.5.tar.gz
Size 51.6 kB
Tags Source
SHA-256 checksum
How to use checksums
63718a098a4a14306212b98d8b9c57ef579b4374977dcfeca0744048307bf468
BLAKE2b-256 checksum
How to use checksums
f0b51dd039a6f48eb54c3f6c6db6d4ca41b438c2f7b50896a654f2c3b247632f
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 Sep 21, 2026.

Transparency log

Release files / fs_schema-0.4.5-py3-none-any.whl

Download URL fs_schema-0.4.5-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d2f104d6418dc59e3abcfdbdcea6a4c9c57ac0fbf116f137541436456e46a66
BLAKE2b-256 checksum
How to use checksums
c87c011a49f2d65ed0df70e3edb622a2bfdbe6061883a3b177270c769c38df9a
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 Sep 21, 2026.

Transparency log

Release history Release notifications | RSS feed

0.6.0

2 release files

0.4.6

2 release files

This release

0.4.5 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