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.7.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.7.0
File Size Uploaded
fs_schema-0.7.0.tar.gz 66.1 kB Details

Built distribution (wheel)

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

Total release size: 90.9 kB

Release files / fs_schema-0.7.0.tar.gz

Download URL fs_schema-0.7.0.tar.gz
Size 66.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d838ff8c629f6352622ab7da25dafcdece6151c21b6cea4f0f72643b33e4e982
BLAKE2b-256 checksum
How to use checksums
bfe4f427bf3c8e5a641587206648a31d5ab9f60be97c41f220e44be4a488a42c
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 25, 2026.

Transparency log

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

Download URL fs_schema-0.7.0-py3-none-any.whl
Size 24.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6713139667a495ce5c20aecb9068d86d0071700fadaa4bd681dcb1cf6a904a9b
BLAKE2b-256 checksum
How to use checksums
8a2bf0cfaf74e81018d4a02dbb0d410593ca759eaa4419df5f730ef932358a02
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 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 release files

0.6.0

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