A flock of typed, zero-dependency Python design patterns. Each pattern is a single self-contained pato (a duck you adopt), fully typed, standard library only, and small enough to read in one sitting.
Install
pip install patos
Or copy a single duck. Open its docs page, copy the source from the Source section, and paste it into your own project. No dependency, no version pin, no tool, just one module you own.
The pydantic house models (Model, FrozenModel, Component, ...) live in patos.models and
install pydantic only when a project asks for them.
pip install "patos[models]"
from patos.models import FrozenModel
The optional PostgreSQL toolkit installs SQLAlchemy, pgvector, and inflection only when a project asks for them.
pip install "patos[sql]"
from patos import sql
Patterns
Creational
| pato | description | docs |
|---|---|---|
Singleton |
one instance per class, __init__ runs once |
docs |
FlyweightMeta |
a metaclass that interns instances by constructor args, build-once and immutable | docs |
Dispatch & selection
| pato | description | docs |
|---|---|---|
Registry |
self-registering class hierarchies via __init_subclass__, with try-each dispatch, select(predicate) and first_available() |
docs |
Strategy |
a named family of interchangeable implementations, with first_available() |
docs |
value_dispatch |
dispatch on a value the way singledispatch dispatches on a type |
docs |
type_dispatch |
dispatch on the first argument's type, the open-type-ladder dual of value_dispatch |
docs |
Structural & lifecycle
| pato | description | docs |
|---|---|---|
Decorator |
a transparent wrapper that forwards everything to the wrapped object but what it overrides | docs |
Pipeline |
a reversible stack of stages, applied forward and unwound in reverse around a core op | docs |
Lifecycle |
a typed state machine that permits only the transitions its table declares | docs |
DerivedCache |
a load-once cache of a derived value keyed by exactly what it depends on | docs |
Command-line
| pato | description | docs |
|---|---|---|
StrFlag |
an enum Flag whose members carry a literal string, OR-combinable and iterable |
docs |
Research registration
| pato | description | docs |
|---|---|---|
SourceRegistration |
binds one research node to the exact source set governing a run and seals it | |
statement_bytes |
the sealed statement of a node file, front matter and settlement sections excluded | |
sha256_text_file, sha256_text_sources |
checkout-independent digests of registered text |
The seal covers the node's statement and the whole bytes of every other registered source. The
statement starts at the first ## heading after the front matter and ends before the first
## Evidence, ## Ledger or ## Log heading, matched without regard to case. Front matter is
never sealed, so status, date and the registration_sha256 field itself move freely, and a
node that settles and appends to its log still verifies against the claim it was registered under.
Every source is hashed as relative POSIX path \0 LF-normalized bytes \0, ordered by path, which
keeps one seal identical on Windows and POSIX checkouts alike.
Optional extensions
| namespace | description | docs |
|---|---|---|
sql |
typed SQLModel columns, native PostgreSQL enums, pgvector cosine distance, JSONB reads, and set based SQL helpers | docs |
Example
from patos import Singleton
class Settings(Singleton):
def __init__(self) -> None:
self.debug = False
a = Settings()
a.debug = True
b = Settings() # same object, __init__ did not run again
assert a is b and b.debug
Documentation
Full documentation lives at phvv.me/patos.
Development
- Install:
pip install -e ".[dev]" - Lint:
ruff check . && ruff format --check . - Typecheck:
pyrefly check - Test:
pytest - Docs:
pip install -e ".[docs]" && mkdocs build - Build:
python -m build
Metadata
Release files for patos 0.0.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| patos-0.0.15.tar.gz | 746.5 kB | With provenance | Details for patos-0.0.15.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| patos-0.0.15-py3-none-any.whl | Python 3 | none | any | Details for patos-0.0.15-py3-none-any.whl |
Total release size: 909.7 kB
Release files / patos-0.0.15.tar.gz
| Download URL | patos-0.0.15.tar.gz |
|---|---|
| Size | 746.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
80bad5fec57f5090207ec891e439c52db2ea3548c4dccfc9d399ffce064f0d26
|
|
BLAKE2b-256 checksum How to use checksums |
e351e8880053918ae02783e0a7b0861e5b0d6b65230381f0db90bf754e8b641e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 2, 2026.
Transparency logRelease files / patos-0.0.15-py3-none-any.whl
| Download URL | patos-0.0.15-py3-none-any.whl |
|---|---|
| Size | 163.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
24fdf6a54bb5e06486e4d3dfd84fb70f2becd1002d89209ab681129e865aeb89
|
|
BLAKE2b-256 checksum How to use checksums |
caf1e951da23768f3994268dabfa81c18a2bd29754577eef39d0d6e55f4cd4c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 2, 2026.
Transparency logSecurity for patos 0.0.15
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for patos-0.0.15.tar.gz
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 Nov 2, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.