Typed Python design and dispatch patterns, pip one in or copy one in and own the file
Project description
patos
A flock of typed Python patterns. Pip one in, or copy one in and own the file.
Each pattern is a single self-contained pato, a duck you adopt. Every duck is fully typed,
standard library only, and small enough to read in one sitting.
Two ways to use a pato
Install the whole flock and import the patterns you want.
pip install patos
from patos import Registry
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.
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
The flock
| pato | does |
|---|---|
registry |
self-registering class hierarchies via __init_subclass__ |
singleton |
one instance per class, __init__ runs once |
flyweight |
intern instances by constructor args, build-once and immutable |
strategy |
a named family of interchangeable implementations |
dispatch |
dispatch on a value the way singledispatch dispatches on a type |
flags |
turn keyword options into a CLI argv tuple |
strflag |
an enum Flag whose members carry a literal string, OR-combinable and iterable |
Documentation
Full documentation lives at https://phvv.me/patos.
Development
This project's dev environment is managed by chefe.
- Install:
chefe install - Lint:
chefe run lint - Typecheck:
chefe run typecheck - Test:
chefe run test - Docs:
chefe run docs - Build:
uv build
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file patos-0.0.1.tar.gz.
File metadata
- Download URL: patos-0.0.1.tar.gz
- Upload date:
- Size: 27.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f746861c82fd76daf4dde0ac4d3e5a29bf0695836a289d951c7a41e5f7d00339
|
|
| MD5 |
0b7513ddc62501b5299bb6b17befb778
|
|
| BLAKE2b-256 |
0098cf47484888ba8cbddf2676c95f64a67d6cef4bf6e6fe444efe60ea74612e
|
Provenance
The following attestation bundles were made for patos-0.0.1.tar.gz:
Publisher:
publish.yml on phvv-me/patos
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
patos-0.0.1.tar.gz -
Subject digest:
f746861c82fd76daf4dde0ac4d3e5a29bf0695836a289d951c7a41e5f7d00339 - Sigstore transparency entry: 1754643757
- Sigstore integration time:
-
Permalink:
phvv-me/patos@3632f0fdc68bf82848a82841e1e429e8af2dd09c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/phvv-me
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3632f0fdc68bf82848a82841e1e429e8af2dd09c -
Trigger Event:
push
-
Statement type:
File details
Details for the file patos-0.0.1-py3-none-any.whl.
File metadata
- Download URL: patos-0.0.1-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9171b9ef8e685368e2e99a14397f7d962ff5b5dd3bf544655b6f3dc608bed5ed
|
|
| MD5 |
fcb0d4ba1025a4317743816dfb0edfa8
|
|
| BLAKE2b-256 |
a2394007645e76ee06ab0a3669adbbee764635ba15191bddccc3a43cd90bc13e
|
Provenance
The following attestation bundles were made for patos-0.0.1-py3-none-any.whl:
Publisher:
publish.yml on phvv-me/patos
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
patos-0.0.1-py3-none-any.whl -
Subject digest:
9171b9ef8e685368e2e99a14397f7d962ff5b5dd3bf544655b6f3dc608bed5ed - Sigstore transparency entry: 1754643787
- Sigstore integration time:
-
Permalink:
phvv-me/patos@3632f0fdc68bf82848a82841e1e429e8af2dd09c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/phvv-me
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3632f0fdc68bf82848a82841e1e429e8af2dd09c -
Trigger Event:
push
-
Statement type: