Pydantic v2 models and typed ruleset loaders for Datasworn JSON.
Use these to parse and validate Ironsworn / Starforged / Sundered Isles / Lodestar / Delve / community-expansion content into typed Python objects instead of raw dict.
Each ruleset ships as its own PyPI package so you can pull only the rulesets your app cares about. Nothing is on PyPI yet — see the Status section below.
pip install datasworn-community-core # types + Pydantic models (required by everything else)
pip install datasworn-community-classic # Ironsworn Classic ruleset JSON
pip install datasworn-community-delve # Ironsworn Delve
pip install datasworn-community-lodestar # Ironsworn Lodestar
pip install datasworn-community-starforged # Ironsworn Starforged
pip install datasworn-community-sundered-isles
pip install datasworn-community-starsmith
pip install datasworn-community-ironsmith
pip install datasworn-community-ancient-wonders
pip install datasworn-community-fe-runnersuv add "datasworn-community-core @ git+https://github.com/datasworn-community/python-bindings.git#subdirectory=packages/core"
uv add "datasworn-community-classic @ git+https://github.com/datasworn-community/python-bindings.git#subdirectory=packages/classic"import importlib
import json
from pathlib import Path
from datasworn.core.models import Ruleset, Expansion
pkg = importlib.import_module("datasworn.starforged")
json_file = Path(pkg.__file__).parent / "json" / "starforged.json"
with json_file.open() as f:
data = json.load(f)
rules: Ruleset = Ruleset.model_validate(data)
print(rules.id, len(rules.moves or {}), len(rules.oracles or {}))Note: PyPI package names use hyphens (datasworn-community-classic) but Python import paths use dots (from datasworn.classic import ...). This mirrors the bs4 / beautifulsoup4 convention.
Everything is functional, but there are known gaps to reconcile before the first PyPI release:
- Pydantic pinned
<2.13. Pydantic 2.13 tightened validation in two ways that the generatedmodels.pyisn't yet reconciled with:datefields carry a stringpatternconstraint that 2.13 rejects (fix stripped frommodels.pyfor now — needs a proper generator fix so it doesn't come back on regeneration).- Delve's
site_domains.*.features/.dangersare typed as models but the compiled JSON emits them as lists. Delve tests are markedxfailuntil this is resolved.
models.pyhas not been post-processed to convertRootModel[str]wrappers into plain type aliases. That's the ergonomic (.idvs._id) fix that was in a separate script on the upstream fork.
Uses uv for workspace management.
uv sync
uv run pytest -q tests/The workspace publishes 10 packages (1 core + 9 rulesets). Adding a new ruleset:
- Copy an existing ruleset directory under
packages/and rename it (e.g.cp -R packages/starsmith packages/new_ruleset). - Update the copy's
pyproject.toml—name,module-name, and description. - Rename the module directory under
src/to match. - Drop the correct
<ruleset>.jsonintosrc/.../json/. - Add the workspace member to root
pyproject.toml's[tool.uv.workspace] membersand[tool.uv.sources]. - Add the ruleset name to
OFFICIAL_PACKAGESorCOMMUNITY_PACKAGESintests/test_load_rules_packages.py.
Ported from tbsvttr/datasworn pkg/python/ — the two nested workspaces (datasworn/ and datasworn-community-content/) merged into a single flat workspace here for simpler consumer install.
Original author: Gerhard Brandt (gbrandt1), who built the Pydantic binding on the fork.
- Schema + types (TypeScript):
datasworn-community/datasworn— publishes@datasworn-community/core - Official content:
datasworn-community/official-content - Community content:
datasworn-community/community-content - Web viewer:
datasworn-community/viewer— live at https://datasworn-community.github.io/viewer/