Skip to main content

Injection of dependencies for python 3

Project description

A bag of objects for Python

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, b: B):
        self.b = b

class B:
    pass

svc = {
    'a': A,
    'b': B,
}
context = Pytel(svc)
assert context.a.b == context.b

See usage for more cases

Features

  • Build a graph of objects based on init methods or factory functions

  • Initialize from
    • a dictionary of string to any of:
      • callable

      • type

      • value

    • Object containing any of:
      • object fields with objects or types (or callables)

      • class fields with objects or types (or callables)

      • methods

      • static methods

    • An Iterable of the above

  • Verify integrity of the dependency graph using type annotations

  • Recurrently resolve all dependencies at the first reference

  • Works as a Context Manager, on __exit__ close all objects that are Context Managers

Because of strict type checking this package is probably quite unpythonic.

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.5.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytel_inject-0.5.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file pytel-inject-0.5.1.tar.gz.

File metadata

  • Download URL: pytel-inject-0.5.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.6 Linux/5.0.0-1031-gcp

File hashes

Hashes for pytel-inject-0.5.1.tar.gz
Algorithm Hash digest
SHA256 f876ab7155e8f7d480dd626ba20946ab21e7d7c4bd1284d547c340ae4e35da4b
MD5 34d6451db8dedfeebd3c9f5382188e20
BLAKE2b-256 6444e5555d2973f9aef6c3d51f6002ef6f42772fdcfde4ce8145ab18abee0dc9

See more details on using hashes here.

File details

Details for the file pytel_inject-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: pytel_inject-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.6 Linux/5.0.0-1031-gcp

File hashes

Hashes for pytel_inject-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 52c960b07f9dfadcacc190a22328100c3b0011a0eba67e46894c08d81a1df925
MD5 996ec00d9c2e044ad2e1f3541832fd30
BLAKE2b-256 5476db2389715168e7c881b50681c6abbd4c650d58504331d69e1da712f62cbe

See more details on using hashes here.

Supported by

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