Skip to main content

Arcanus

Tests Codecov CodSpeed Docs Python 3.11+ License: MIT

Arcanus is a small library that binds Pydantic schemas to your datasource. The idea is to let you work with one set of typed, validated objects that are backed by your real backend records — so the templates, factories, and converters that usually sit between validation and persistence mostly fall away. If that boilerplate has bothered you too, this is the approach Arcanus takes to it.

It's a different take from SQLModel, which fuses the Pydantic model and the ORM table into one class. Arcanus instead keeps them separate and binds a schema to your existing ORM model with bless(), so your SQLAlchemy models stay untouched and your validation schema stays your own.

⚠️ Work in progress. Arcanus is at an early, minimum-viable stage — expect bugs and breaking changes. SQLAlchemy is currently the only supported backend.

Features

  • 🔄 Unified objects — transmuters are backed by ORM objects; changes sync both ways, no manual conversion.
  • 🛡️ Type safety — full Pydantic validation, plus typed column references like Author["name"].
  • 🔗 Relationships — one-to-one, one-to-many, many-to-many, and keyed maps that respect lazy loading.
  • Async — native async/await via AsyncSession.
  • 🎯 Pluggable backendsNoOpMateria for tests, SqlalchemyMateria for databases.
  • 📦 Partial models — built-in Create / Update shapes for API boundaries.

Installation

pip install "arcanus[sqlalchemy]"

The base pip install arcanus ships the in-memory NoOpMateria (no backend needed) — ideal for tests and prototyping.

Quickstart

from arcanus.base import BaseTransmuter, Identity
from arcanus.association import (
    Relation,
    RelationCollection,
    Relationship,
    Relationships,
)
from arcanus.materia.sqlalchemy import SqlalchemyMateria, Session
from pydantic import Field
from sqlalchemy import create_engine, select
from typing import Annotated, Optional

materia = SqlalchemyMateria()


@materia.bless(AuthorModel)  # bind to your existing SQLAlchemy model
class Author(BaseTransmuter):
    id: Annotated[Optional[int], Identity] = Field(default=None, frozen=True)
    name: str
    books: RelationCollection["Book"] = Relationships()


@materia.bless(BookModel)
class Book(BaseTransmuter):
    id: Annotated[Optional[int], Identity] = Field(default=None, frozen=True)
    title: str
    author: Relation[Author] = Relationship()


with Session(create_engine("sqlite://")) as session:
    author = Author(name="Isaac Asimov")
    session.add(Book(title="Foundation", author=Relation(author)))
    session.commit()

    # Plain SQLAlchemy reads — only the results come back as transmuters
    found = session.execute(
        select(Author).filter_by(name="Isaac Asimov")
    ).scalar_one()  # a transmuter, not a raw ORM row
    for book in found.books:  # loads on access
        print(book.title, book.author.value is found)  # identity preserved

See the Quickstart guide for the full walkthrough including the ORM model definitions and async usage.

Documentation

Full documentation lives at kalynnka.github.io/arcanus:

Contributing

See CONTRIBUTING.md for branch naming, conventional commits, and the release flow.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arcanus-0.0.26.tar.gz (345.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

arcanus-0.0.26-py3-none-any.whl (65.8 kB view details)

Uploaded Python 3

File details

Details for the file arcanus-0.0.26.tar.gz.

File metadata

  • Download URL: arcanus-0.0.26.tar.gz
  • Upload date:
  • Size: 345.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for arcanus-0.0.26.tar.gz
Algorithm Hash digest
SHA256 6cc2a58c6ef442312c716b7d6d8caa3191dce04293e49b01ecfba4413ecc3a8a
MD5 0c943e670cfc7233e9c490e1b2eee720
BLAKE2b-256 8628a0a0986d0e598397e4b49487ce30ced984b0e496ca72986b9ca716fbca25

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcanus-0.0.26.tar.gz:

Publisher: publish.yml on kalynnka/arcanus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arcanus-0.0.26-py3-none-any.whl.

File metadata

  • Download URL: arcanus-0.0.26-py3-none-any.whl
  • Upload date:
  • Size: 65.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for arcanus-0.0.26-py3-none-any.whl
Algorithm Hash digest
SHA256 4fdced77c258b6967ddf392fa853cbf30c4a18ceeb0c629d15014a1ae82a01ef
MD5 5b79692ce1a16ffa31b7419c2887002a
BLAKE2b-256 6b84466fd1e4369e1cd5f85d53993052aedd02cf093616800e07272b67a0ea05

See more details on using hashes here.

Provenance

The following attestation bundles were made for arcanus-0.0.26-py3-none-any.whl:

Publisher: publish.yml on kalynnka/arcanus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.0.28

2 files

0.0.27

2 files

This release

0.0.26 This release

2 files

0.0.25

2 files

0.0.24

2 files

0.0.23

2 files

0.0.22

2 files

0.0.21

2 files

0.0.20

2 files

0.0.19

2 files

0.0.18

2 files

0.0.17

2 files

0.0.16

2 files

0.0.15

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 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