Skip to main content

Dependency injection framework using pure Python

Project description

Prion

A dependency injection framework using pure Python. No external dependencies.

Installation

pip install prion

Usage

Define a container by subclassing Syringe and declaring dependencies with single() or factory().

>>> from prion import Syringe, single, factory

>>> class AppSyringe(Syringe):
...     config: dict = single()
...     session: dict = factory()

Create an instance and register providers using decorators.

>>> syringe = AppSyringe()

>>> @syringe.config
... def create_config() -> dict:
...     return {"debug": True}

>>> @syringe.session
... def create_session() -> dict:
...     return {}

Access dependencies as attributes.

>>> syringe.config is syringe.config
True

>>> syringe.session is not syringe.session
True

Strategies

Strategy Behavior
single() Creates once, returns cached
factory() Creates a new instance each time

License

MIT

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

prion-0.1.0.tar.gz (1.9 kB view details)

Uploaded Source

Built Distribution

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

prion-0.1.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file prion-0.1.0.tar.gz.

File metadata

  • Download URL: prion-0.1.0.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for prion-0.1.0.tar.gz
Algorithm Hash digest
SHA256 12f65cb10da990c2d95ce5d106f347ee2320f308ec78fd397ed03adfcea8e357
MD5 5a364815c3ce723c62c3fe3dc6a9121c
BLAKE2b-256 2d3210d393a34caf6119fb2d9bc3199f0abc64e2bca524da8a7875274a7fd34b

See more details on using hashes here.

File details

Details for the file prion-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: prion-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for prion-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b8a4e77b6437567013d879d9d835a48e2774aa00ae31a86f8004fb2c9ce0f01
MD5 5746b67d138058ba0b1fea7665d12a9d
BLAKE2b-256 12ee8c8be6780326881ddd80897800eb5a40e236bee3924a8e63592e32ba71ec

See more details on using hashes here.

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