Skip to main content

Typed Python design and dispatch patterns, pip one in or copy one in and own the file

Project description

patos

CI Docs License

🇧🇷 🇲🇽 🇯🇵 🇨🇳

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

patos-0.0.1.tar.gz (27.2 kB view details)

Uploaded Source

Built Distribution

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

patos-0.0.1-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

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

Hashes for patos-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f746861c82fd76daf4dde0ac4d3e5a29bf0695836a289d951c7a41e5f7d00339
MD5 0b7513ddc62501b5299bb6b17befb778
BLAKE2b-256 0098cf47484888ba8cbddf2676c95f64a67d6cef4bf6e6fe444efe60ea74612e

See more details on using hashes here.

Provenance

The following attestation bundles were made for patos-0.0.1.tar.gz:

Publisher: publish.yml on phvv-me/patos

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

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

Hashes for patos-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9171b9ef8e685368e2e99a14397f7d962ff5b5dd3bf544655b6f3dc608bed5ed
MD5 fcb0d4ba1025a4317743816dfb0edfa8
BLAKE2b-256 a2394007645e76ee06ab0a3669adbbee764635ba15191bddccc3a43cd90bc13e

See more details on using hashes here.

Provenance

The following attestation bundles were made for patos-0.0.1-py3-none-any.whl:

Publisher: publish.yml on phvv-me/patos

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page