GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - 100nm/python-injection: Dead-simple dependency injection framework for Python.

BranchesTags
Open more actions menu

Latest commit

 

History

277 Commits
277 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
docs
docs
 
 
injection
injection
 
 
tests
tests
 
 
typing_checks
typing_checks
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
conftest.py
conftest.py
 
 
mkdocs.yml
mkdocs.yml
 
 
pyproject.toml
pyproject.toml
 
 
uv.lock
uv.lock
 
 

Repository files navigation

python-injection

PyPI - Version PyPI - Downloads GitHub Stars CI Ruff

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.

from injection import injectable, inject, singleton


@singleton
class Printer:
    def __init__(self):
        self.history = []

    def print(self, message: str):
        self.history.append(message)
        print(message)


@injectable
class Service:
    def __init__(self, printer: Printer):
        self.printer = printer

    def hello(self):
        self.printer.print("Hello world!")


@inject
def main(service: Service):
    service.hello()


if __name__ == "__main__":
    main()

About

Dead-simple dependency injection framework for Python.

python-injection.remimd.dev

Topics

anyioasyncasync-pythondecoratorsdecorators-pythondependency-injectiondependency-injection-frameworkdifastapiinversion-of-controliocmypypythontype-hintstyped

Resources

Readme
MIT license
Activity
Custom properties

Stars

127 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Sponsor this project

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.