Skip to main content

fs-schema

PyPI Python License

tests coverage Typed docs

Status releases

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 · Changelog · Source · MIT LICENSE

Changelog

--8<-- "CHANGELOG.md"

Release files for fs-schema 0.6.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 fs-schema 0.6.0
File Size Uploaded
fs_schema-0.6.0.tar.gz 61.7 kB Details

Built distribution (wheel)

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

Total release size: 85.6 kB

Release files / fs_schema-0.6.0.tar.gz

Download URL fs_schema-0.6.0.tar.gz
Size 61.7 kB
Tags Source
SHA-256 checksum
How to use checksums
23c6d26466a266e639299539476852de845a3cbe3f28ba1d2ff009b0b75a89f4
BLAKE2b-256 checksum
How to use checksums
610c50001040577318ddd6ed8f10e6ffaca9652b177dc4ee8387801267b80674
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 24, 2026.

Transparency log

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

Download URL fs_schema-0.6.0-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0bef2e48a31ed1684ff24a38e9383a1246b182c9fc660ca898d06600c347bb00
BLAKE2b-256 checksum
How to use checksums
eaa50bd9acf656fc98eba496b56ea640cdcb39c59e95b7a9025e6eb20bdee7b7
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 24, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.4.6

2 release files

0.4.5

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