Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Dead-simple dependency injection framework for Python.

License

NotificationsYou must be signed in to change notification settings

100nm/python-injection

Repository files navigation

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()

[8]ページ先頭

©2009-2025 Movatter.jp