🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

pytel-inject

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pytel-inject

Injection of dependencies for python 3

0.5.1
PyPI
Maintainers
1

A bag of objects for Python

.. image:: https://img.shields.io/pypi/v/pytel-inject.svg?style=flat :target: https://pypi.org/project/pytel-inject/

.. image:: https://travis-ci.com/mattesilver/pytel.svg :target: https://travis-ci.com/mattesilver/pytel

.. image:: https://codecov.io/gh/mattesilver/pytel/branch/master/graph/badge.svg :target: https://codecov.io/gh/mattesilver/pytel

For when your object graph is too big

.. code-block:: python

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 <https://github.com/mattesilver/pytel/blob/master/tests/pytel/test_usage.py>_ 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.

Keywords

injection-of-dependencies

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts