Skip to main content

Injection of dependencies for python 3

Project description

https://img.shields.io/pypi/v/pytel-inject.svg?style=flat https://travis-ci.com/mattesilver/pytel.svg https://codecov.io/gh/mattesilver/pytel/branch/master/graph/badge.svg

For when your object graph is too big

class A:
  def __init__(self, context: Pytel):
      self.b = context.b

class B:
    pass

context = Pytel()
context.a = lazy(A)(context)
context.b = lazy(B)

assert context.a.b == context.b

Works with dependency cycles (through a proxy object):

class A:
  def __init__(self, context: Pytel):
    self.b = context.b

class B:
  def __init__(self, context: Pytel):
    self.a = context.a

context = Pytel()
context.a = lazy(A)(context)
context.b = lazy(B)(context)

assert context.a.b == context.b
assert context.b.a == context.a

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

pytel-inject-0.2.1.tar.gz (8.8 kB view hashes)

Uploaded Source

Built Distribution

pytel_inject-0.2.1-py3-none-any.whl (9.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