Skip to main content

Gluer

Dependency Injection for Python

Installation

Gluer uses type annotations, so python 3.6+ is required

python3 -m pip install --user gluer

Usage

Let's follow a wonderful explanation of DI:

from abc import ABC, abstractmethod
from gluer import Gluer

class Drink(ABC): # this doesn't *have* to be abstract
	@abstractmethod
	def sip(self):
		pass


class Child:
	def __init__(self, drink: Drink):
		self.drink = drink

	def take_a_sip(self):
		self.drink.sip()
		print("ahhh")


class Juice(Drink):
	def sip(self):
		print("*gulp*")


class Coke(Drink):
	def sip(self):
		print("*fizzle*")



if __name__ == "__main__":
	gluer = Gluer()
	mom_watches = True

	gluer.register(Child)
	gluer.register(Juice if mom_watches else Coke).As(Drink)

	container = gluer.build()

	kid = container.resolve(Child)
	kid.take_a_sip() # *gulp* ahhh

Metadata

Release files for gluer 0.2.0

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

Source distribution (sdist)

Source distribution for gluer 0.2.0
File Size Uploaded Provenance Actions
gluer-0.2.0.tar.gz 3.6 kB Without provenance Details for gluer-0.2.0.tar.gz

Release files / gluer-0.2.0.tar.gz

Download URL gluer-0.2.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6492e1bd54befac2d7f8dd453e83b314ade314b139aad30f3fb642979813d25d
BLAKE2b-256 checksum
How to use checksums
a89453db582549eac9d3b547c2da5024b664f5f8c825e4da0141c33ad0ee8e61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6

Security for gluer 0.2.0

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.2.0 This release

1 release file 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