Typed Python design and dispatch patterns, pip one in or copy one in and own the file
Project description
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.
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 |
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 |
Command-line
| pato | description | docs |
|---|---|---|
StrFlag |
an enum Flag whose members carry a literal string, OR-combinable and iterable |
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
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.7.tar.gz.
File metadata
- Download URL: patos-0.0.7.tar.gz
- Upload date:
- Size: 499.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6713139312f29038f36d1c2f878eafac04524e524cafd581ebaba80ac711c11
|
|
| MD5 |
3cda5a9e95742e47599df9066b15f858
|
|
| BLAKE2b-256 |
f1f1f58d64a9dbe2e95ec41541bf9b0a91e252d371997312a70555bc087c9237
|
Provenance
The following attestation bundles were made for patos-0.0.7.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.7.tar.gz -
Subject digest:
d6713139312f29038f36d1c2f878eafac04524e524cafd581ebaba80ac711c11 - Sigstore transparency entry: 1807873126
- Sigstore integration time:
-
Permalink:
phvv-me/patos@c0d61362179318f84d94c0e1aa98377c98877bd2 -
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@c0d61362179318f84d94c0e1aa98377c98877bd2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file patos-0.0.7-py3-none-any.whl.
File metadata
- Download URL: patos-0.0.7-py3-none-any.whl
- Upload date:
- Size: 16.7 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 |
f8fedf8db799f19a66fc2d02c420ee1cffd7b78d1a42bb963bf0f967d49b77cd
|
|
| MD5 |
de7ced5a248bf89dab91b66a7b4687e7
|
|
| BLAKE2b-256 |
0d702b03212a58fc34b4ccb7b97d383ce98b708bd9d46b4aab14dc89d0adf963
|
Provenance
The following attestation bundles were made for patos-0.0.7-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.7-py3-none-any.whl -
Subject digest:
f8fedf8db799f19a66fc2d02c420ee1cffd7b78d1a42bb963bf0f967d49b77cd - Sigstore transparency entry: 1807873129
- Sigstore integration time:
-
Permalink:
phvv-me/patos@c0d61362179318f84d94c0e1aa98377c98877bd2 -
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@c0d61362179318f84d94c0e1aa98377c98877bd2 -
Trigger Event:
push
-
Statement type: