Skip to main content

fs-schema

PyPI Status Python License

tests coverage Typed docs

Release

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.4.6

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.6
File Size Uploaded
fs_schema-0.4.6.tar.gz 52.1 kB Details

Built distribution (wheel)

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

Total release size: 70.2 kB

Release files / fs_schema-0.4.6.tar.gz

Download URL fs_schema-0.4.6.tar.gz
Size 52.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4729009e94e4e28f887c4cec907154e273eb9ac0e829e6c3015e7180dbf91877
BLAKE2b-256 checksum
How to use checksums
f861a26d4001cd57a14eec1a9b634dec9d39590f7e9ac58f55f11135036fa88b
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.6-py3-none-any.whl

Download URL fs_schema-0.4.6-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d191ddc1d258a6cfbf90cd0c57ab28b625a6c9704e59d651a2aeaf48cdfc90c
BLAKE2b-256 checksum
How to use checksums
36f0fd9ceae8040493e026ec79a66317436d6536207cf4cbe74f414534a667c8
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

This release

0.4.6 This release

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