Skip to content

Repository files navigation

python-injection

CIPyPI - VersionPyPI - DownloadsRuff

Documentation: https://python-injection.remimd.dev

Installation

⚠️Requires Python 3.12 or higher

pip install python-injection

Quick start

Simply apply the decorators and the package takes care of the rest.

frominjectionimportinjectable, inject, singleton@singletonclassPrinter:
def__init__(self):
self.history= []
defprint(self, message: str):
self.history.append(message)
print(message)
@injectableclassService:
def__init__(self, printer: Printer):
self.printer=printerdefhello(self):
self.printer.print("Hello world!")
@injectdefmain(service: Service):
service.hello()
if__name__=="__main__":
main()

Releases

Sponsor this project

Used by

Contributors

Languages