Dependency-free dependency injection container for appfx packages.
Project description
appfx-di
appfx-di provides a small, dependency-free dependency injection container for
Python applications and reusable appfx components.
Package identity
| Purpose | Name |
|---|---|
| Distribution | appfx-di |
| Import namespace | appfx.di |
| Repository | https://github.com/Dongbumlee/appfx-di |
| Supported Python | 3.12, 3.13 |
Installation
python -m pip install appfx-di
For local development:
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"
Quickstart
from appfx.di import Container, Lifetime
class Greeter:
def greet(self) -> str:
return "hello"
class LoudGreeter(Greeter):
def greet(self) -> str:
return "HELLO"
container = Container()
container.add_type(Greeter, lifetime=Lifetime.SINGLETON)
container.add_type(Greeter, LoudGreeter, name="loud")
default_greeter = container.get_service(Greeter)
loud_greeter = container.get_service(Greeter, name="loud")
assert default_greeter.greet() == "hello"
assert loud_greeter.greet() == "HELLO"
Scoped services
from appfx.di import Container, Lifetime
container = Container()
container.add_type(RequestState, lifetime=Lifetime.SCOPED)
async with container.create_scope() as scope:
first = scope.get_service(RequestState)
second = scope.get_service(RequestState)
assert first is second
Scoped services must be resolved within an active scope. Scope disposal cleans up
created scoped services in reverse creation order. shutdown_async() cleans up
created singleton instances and clears singleton caches.
Validation
python -m ruff check .
python -m ruff format --check .
python -m pytest --cov
python -m mypy
python -m build
python -m twine check dist\*
Project details
Release history Release notifications | RSS feed
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 appfx_di-0.1.0.tar.gz.
File metadata
- Download URL: appfx_di-0.1.0.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb34625b679d8e2da656d0664f2292c79d3608c118e036e7e36be9f885c749b5
|
|
| MD5 |
2a6da013e1482eabe6f0bb67a71afdba
|
|
| BLAKE2b-256 |
de7583f50eab4065bb52bcfb1f35d26df300298aa57aa52f1fe146e06f42cfb1
|
Provenance
The following attestation bundles were made for appfx_di-0.1.0.tar.gz:
Publisher:
publish.yml on Dongbumlee/appfx-di
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
appfx_di-0.1.0.tar.gz -
Subject digest:
bb34625b679d8e2da656d0664f2292c79d3608c118e036e7e36be9f885c749b5 - Sigstore transparency entry: 1648923627
- Sigstore integration time:
-
Permalink:
Dongbumlee/appfx-di@26668799a844568416e8aeca90cdcc4721147bf1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Dongbumlee
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@26668799a844568416e8aeca90cdcc4721147bf1 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file appfx_di-0.1.0-py3-none-any.whl.
File metadata
- Download URL: appfx_di-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.5 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 |
a63b173a58add39d66e22ffa3c2db6977d4e6ebcd37211b746c77460b2ddbf30
|
|
| MD5 |
956c68e3019c1b1f561c0473881777a3
|
|
| BLAKE2b-256 |
5e95da81dad29b25eb906c6bc3bbdb7913f0bdbc05ec023bad8a4bebb39f8ece
|
Provenance
The following attestation bundles were made for appfx_di-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Dongbumlee/appfx-di
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
appfx_di-0.1.0-py3-none-any.whl -
Subject digest:
a63b173a58add39d66e22ffa3c2db6977d4e6ebcd37211b746c77460b2ddbf30 - Sigstore transparency entry: 1648923699
- Sigstore integration time:
-
Permalink:
Dongbumlee/appfx-di@26668799a844568416e8aeca90cdcc4721147bf1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Dongbumlee
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@26668799a844568416e8aeca90cdcc4721147bf1 -
Trigger Event:
workflow_dispatch
-
Statement type: