Skip to main content

Dependency injection with type hints

Project description

Wint - dependency injection with type hints.

Intro

Wint is a lightweight library that implements dependency injection via type hinting.

This project is in development.

Documentation will come up later.

Examples

from wint import autowired, container


class Printer:
    def print(self, message):
        raise NotImplementedError


class RealPrinter(Printer):

    def print(self, message):
        print(message)


@autowired()
class PrintService:
    printer: Printer  # RealPrinter will be automatically injected as instance property

    def run(self, msg):
        self.printer.print(f"{msg}, i'm printing!")


if __name__ == "__main__":
    container.register(Printer, RealPrinter())  # register Printer implementation as singleton.

    PrintService().run('hey')
    >>> hey, i'm printing!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wint-0.1.0.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

wint-0.1.0-py3-none-any.whl (23.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page