Skip to main content

di4injector

DI for Injector

How to use

pip install di4injector
# at example.py

import abc
from di import DIContainer, DI


class GreetingService(abc.ABC):
    @abc.abstractmethod
    def greeting(self) -> str:
        pass

    
class EnglishGreetingService(GreetingService):
    def greeting(self) -> str:
        return 'Hello'


class JapaneseGreetingService(GreetingService):
    def greeting(self) -> str:
        return 'こんにちは'


di = DI.of(
    GreetingService,  # Abstract class 
    {  # inject
        "JP": JapaneseGreetingService,  # DI_PROFILE_ACTIVES=JP,...  
        "EN": EnglishGreetingService    # DI_PROFILE_ACTIVES=EN,...
    }, 
    EnglishGreetingService  # Default
)

DIContainer.instance().register(di)

greeting_service = DIContainer.instance().resolve(GreetingService)
greeting_service.greeting()

For Developer

run test
pytest -v ./tests

Metadata

Release files for di4injector 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for di4injector 0.0.2
File Size Uploaded Provenance Actions
di4injector-0.0.2.tar.gz 2.7 kB Without provenance Details for di4injector-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for di4injector 0.0.2
File Interpreter ABI Platform Actions
di4injector-0.0.2-py3-none-any.whl Python 3 none any Details for di4injector-0.0.2-py3-none-any.whl

Total release size: 5.7 kB

Release files / di4injector-0.0.2.tar.gz

Download URL di4injector-0.0.2.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ecd897055a75f8f73cbaeca21d6ddfea8d895c0ba5f66ad800ab49948a1e81b4
BLAKE2b-256 checksum
How to use checksums
f716d4690e7b958f31939270fa583ce03ee5dbfa13f6a7556c7324c911ae8291
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release files / di4injector-0.0.2-py3-none-any.whl

Download URL di4injector-0.0.2-py3-none-any.whl
Size 3.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7260f610edc3be305799858d1e4b298001d5d0951d434b577b68e4d75f0c2b65
BLAKE2b-256 checksum
How to use checksums
817b4347b2aecce89a1b8a3b21401e0a41f2aa895cc52c48678682da96fce1d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Security for di4injector 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page