Skip to main content

Dependency Injector

AppVeyor CircleCI Travis PyPI - Downloads

Very fast Dependency Injection for Python, which is highly uses typing features. Sometimes faster then similar call in Python.

Requirements

  • Only works with Python 3.7 or greater

  • c++ 11 comaptible compiler. (only if u want to build from source)

    Wheels provided for windows x86/x64 and linux x86/x64

Usage

from typing import Generic, TypeVar
from yapic.di import *


T = TypeVar("T")

class Car(Generic[T]):
   engine: T

   def __init__(self, engine: T):
      self.engine = engine

# simplified Car class
class Car(Generic[T]):
   engine: Inject[T]

class Gasoline:
   pass

class Diesel:
   pass

class Electronic:
   pass

class DieselCar(Car[Diesel]):
   pass

ELECTRONIC_CAR = Token("ELECTRONIC_CAR")

injector = Injector()
injector.provide(Gasoline)
injector.provide(Diesel)
injector.provide(Electronic)
injector.provide(DieselCar)
injector.provide(ELECTRONIC_CAR, Car[Electronic])

diesel = injector[DieselCar]
assert isinstance(diesel, DieselCar)
assert isinstance(diesel.engine, Diesel)

electronic = injector[ELECTRONIC_CAR]
assert isinstance(electronic, Car)
assert isinstance(electronic.engine, Electronic)

def drive_diesel(car: DieselCar):
   assert isinstance(car, DieselCar)
   assert isinstance(car.engine, Diesel)

injector.exec(drive_diesel)

# you can set constant values, like a dict
MEANING_OF_LIFE = Token("MEANING_OF_LIFE")
injector[MEANING_OF_LIFE] = 42
assert injector[MEANING_OF_LIFE] == 42

def question(q: MEANING_OF_LIFE):
   assert q == 42

injector.exec(question)

# cached injectable
life_q = Injectable(question)

# this is same as with injector.exec(question), but injectable is precached
life_q(injector)

Keyword Only Arguments

class Config(dict):
   def __init__(self):
      super().__init__(some_key=42)

def get_kwarg(config: Config, *, name, type):
      if name == "some_key":
         return config[name]
      else:
         raise NoKwOnly()

 def fn(*, some_key: str):
     assert some_key == 42

injector = Injector()
injector.provide(Config)
injector.provide(fn, provide=[KwOnly(get_kwarg)])

For more info see Python Stub file or test files

Release Process

  • change VERSION in setup.py

  • git add setup.py

  • git commit -m "chore(bump): VERSION"

  • git checkout release

  • git merge master

  • git tag -a VERSION -m "chore(bump): VERSION"

  • git push && git push --tags

  • git checkout master

  • git merge release

Metadata

Release files for yapic.di 2.0.12

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

Source distribution (sdist)

Source distribution for yapic.di 2.0.12
File Size Uploaded Provenance Actions
yapic.di-2.0.12.tar.gz 40.3 kB Without provenance Details for yapic.di-2.0.12.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for yapic.di 2.0.12
File Actions
yapic.di-2.0.12-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for yapic.di-2.0.12-cp311-cp311-win_amd64.whl
yapic.di-2.0.12-cp311-cp311-win32.whl CPython 3.11 CPython 3.11 Windows x86-32 Details for yapic.di-2.0.12-cp311-cp311-win32.whl
yapic.di-2.0.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details for yapic.di-2.0.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
yapic.di-2.0.12-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for yapic.di-2.0.12-cp310-cp310-win_amd64.whl
yapic.di-2.0.12-cp310-cp310-win32.whl CPython 3.10 CPython 3.10 Windows x86-32 Details for yapic.di-2.0.12-cp310-cp310-win32.whl
yapic.di-2.0.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details for yapic.di-2.0.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
yapic.di-2.0.12-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details for yapic.di-2.0.12-cp39-cp39-win_amd64.whl
yapic.di-2.0.12-cp39-cp39-win32.whl CPython 3.9 CPython 3.9 Windows x86-32 Details for yapic.di-2.0.12-cp39-cp39-win32.whl
yapic.di-2.0.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details for yapic.di-2.0.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
yapic.di-2.0.12-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details for yapic.di-2.0.12-cp39-cp39-macosx_10_9_x86_64.whl
yapic.di-2.0.12-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details for yapic.di-2.0.12-cp38-cp38-win_amd64.whl
yapic.di-2.0.12-cp38-cp38-win32.whl CPython 3.8 CPython 3.8 Windows x86-32 Details for yapic.di-2.0.12-cp38-cp38-win32.whl
yapic.di-2.0.12-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details for yapic.di-2.0.12-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
yapic.di-2.0.12-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details for yapic.di-2.0.12-cp38-cp38-macosx_10_9_x86_64.whl
yapic.di-2.0.12-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details for yapic.di-2.0.12-cp37-cp37m-win_amd64.whl
yapic.di-2.0.12-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details for yapic.di-2.0.12-cp37-cp37m-win32.whl
yapic.di-2.0.12-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 Details for yapic.di-2.0.12-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
yapic.di-2.0.12-cp37-cp37m-macosx_10_9_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 Details for yapic.di-2.0.12-cp37-cp37m-macosx_10_9_x86_64.whl

Total release size: 2.4 MB

Release files / yapic.di-2.0.12.tar.gz

Download URL yapic.di-2.0.12.tar.gz
Size 40.3 kB
Tags Source
SHA-256 checksum
How to use checksums
43dd741f73a03baa2524478ef651dcdba40140615dc71df2d20a9e1852719c0e
BLAKE2b-256 checksum
How to use checksums
4e1f2e3199ed44536e82af0ad95171170fc01c0b9459f68021f2698732b78815
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / yapic.di-2.0.12-cp311-cp311-win_amd64.whl

Download URL yapic.di-2.0.12-cp311-cp311-win_amd64.whl
Size 41.1 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
39265574e1a92e9fa03781411310da01bed663ae441e55ea0725a67d443aec1f
BLAKE2b-256 checksum
How to use checksums
f2d8009d7bfa7b48d3edb7943865e0e35f678da6ed23ad74dff3c65046655e01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / yapic.di-2.0.12-cp311-cp311-win32.whl

Download URL yapic.di-2.0.12-cp311-cp311-win32.whl
Size 37.3 kB
Tags CPython 3.11 Windows x86-32
SHA-256 checksum
How to use checksums
b0eb462eef2bf721ca3ab0684a18be30af02a0a96f33497520608664f2327f2e
BLAKE2b-256 checksum
How to use checksums
ce0e35b7ecccd45d765709475b65448fbc9667eb48f7916656c7fd73ad5a01ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / yapic.di-2.0.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL yapic.di-2.0.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 362.9 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
b316d5e3f2bc663db3d7888af55a4aca3f15dcd3ca889ae03ae5744af34518e2
BLAKE2b-256 checksum
How to use checksums
eb225fec400b64fc1e8dcf1514a5f6666d5cfbaacb589effd54c937ed2781093
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / yapic.di-2.0.12-cp310-cp310-win_amd64.whl

Download URL yapic.di-2.0.12-cp310-cp310-win_amd64.whl
Size 41.0 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
a9bbc034ad350452e9076900638077acd6923d0521e1846d817561a8d919f247
BLAKE2b-256 checksum
How to use checksums
60545a7ee08b42bfc530a840575322981944266f774050c432913b6798cd5d15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.11

Release files / yapic.di-2.0.12-cp310-cp310-win32.whl

Download URL yapic.di-2.0.12-cp310-cp310-win32.whl
Size 37.3 kB
Tags CPython 3.10 Windows x86-32
SHA-256 checksum
How to use checksums
a9206685af7f222a35c391bf046117d428d2d74cb7f0ffd4658fbef96490303f
BLAKE2b-256 checksum
How to use checksums
a143688909839605c9115f514ac355ca0eda816a4e60b243e6e42ce3bd6c4b1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.11

Release files / yapic.di-2.0.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL yapic.di-2.0.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 343.7 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
eb871f0744c29a45e913327f69eb77855c32ba5a94f00a7f0bb5ec941cb441d3
BLAKE2b-256 checksum
How to use checksums
f30e9faf5a017d462e0435da1cedb9db321faacd22949d781a48e5f432729e94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / yapic.di-2.0.12-cp39-cp39-win_amd64.whl

Download URL yapic.di-2.0.12-cp39-cp39-win_amd64.whl
Size 43.9 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
629163bb0fce6c1fe8de3fce995054e65f6ff2a71a70bf00b5c028f209ab423f
BLAKE2b-256 checksum
How to use checksums
e262b405e6befc0d45ae513f9aa6d9b5bee897d67b1da580be7e7a494d21c306
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / yapic.di-2.0.12-cp39-cp39-win32.whl

Download URL yapic.di-2.0.12-cp39-cp39-win32.whl
Size 39.7 kB
Tags CPython 3.9 Windows x86-32
SHA-256 checksum
How to use checksums
1200b795f7267cc9ada870f24573ecb9d7379bf0f6b20f89ffcd0fe8754076ff
BLAKE2b-256 checksum
How to use checksums
9edeca25a49914c6566de70243d2cf6d621bd2b5b145a4dc42141db565309ed8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / yapic.di-2.0.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL yapic.di-2.0.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 341.6 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
40066404dfdb5002f61cd52e78acbb26902b0a9e1385e21ee9d694cd5a1aafe0
BLAKE2b-256 checksum
How to use checksums
714ddfae472eb1be05d062b8c7af443fb3842a4bb5109cbef882109c1e25071e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / yapic.di-2.0.12-cp39-cp39-macosx_10_9_x86_64.whl

Download URL yapic.di-2.0.12-cp39-cp39-macosx_10_9_x86_64.whl
Size 53.5 kB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
af212d8870478272aced5b605fd7bc4d1f055447975d0731d532417734037264
BLAKE2b-256 checksum
How to use checksums
2be5634dddc73daceb126450485b66106fc3c1ecce1f4f93abf5711af698f6b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / yapic.di-2.0.12-cp38-cp38-win_amd64.whl

Download URL yapic.di-2.0.12-cp38-cp38-win_amd64.whl
Size 44.1 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
7131c8e5144215a2e1b7cf5eaa81b07143195a6d23224c78fb455bc65ab81c97
BLAKE2b-256 checksum
How to use checksums
60c3614e288489c2267daf5a5e3692276f1587a0f3f63807f1da3c1f61c970fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.10

Release files / yapic.di-2.0.12-cp38-cp38-win32.whl

Download URL yapic.di-2.0.12-cp38-cp38-win32.whl
Size 39.8 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
2d37377ebaa871a65edd35941c02dfaa2a150ad5df1e61a582bb63ade0df4655
BLAKE2b-256 checksum
How to use checksums
17a37ee78b226cb363120b214e86f73b9ffe3518b888284a9695c771bf862806
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.10

Release files / yapic.di-2.0.12-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL yapic.di-2.0.12-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 350.7 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
236e471a2289f8605985923284b4edcbb1ea7ca1161ff2401b2e5f904bd643f1
BLAKE2b-256 checksum
How to use checksums
fb8759d2570cba927ef7428e1c1ed8f88f80d4d586048c4e14d466c8032c5812
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / yapic.di-2.0.12-cp38-cp38-macosx_10_9_x86_64.whl

Download URL yapic.di-2.0.12-cp38-cp38-macosx_10_9_x86_64.whl
Size 53.5 kB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
c4f8101f6a561b703afabeca12d7b16c1663146aa1585299387db7fe16ef6414
BLAKE2b-256 checksum
How to use checksums
6dd544df9da9a9aec93f425afb9ccc760fe6d694db1f92612b0663fe9dd6394b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / yapic.di-2.0.12-cp37-cp37m-win_amd64.whl

Download URL yapic.di-2.0.12-cp37-cp37m-win_amd64.whl
Size 44.1 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
f89fb7360bf77489300454f57b26de38473c4da323afa2b30fe7c707cf0cb164
BLAKE2b-256 checksum
How to use checksums
6b71d3245423747c90467249671aee502036b18c3780a81a210b045e13282cdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.9

Release files / yapic.di-2.0.12-cp37-cp37m-win32.whl

Download URL yapic.di-2.0.12-cp37-cp37m-win32.whl
Size 40.7 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
52325d7c6b09b8ea1b5ac04a764a28e4f4c215c1cadb94d96d9646d327430a0a
BLAKE2b-256 checksum
How to use checksums
b3adaa1adc39b67f6aec285fba5de26a855d79a508fed85927ddfab4d95911d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.9

Release files / yapic.di-2.0.12-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL yapic.di-2.0.12-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 346.0 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
b7495d03ce66d143c872d9057cd7b0c17653f1ccbc336d896b93b98ea76607ef
BLAKE2b-256 checksum
How to use checksums
96cd715aa5c9028475994ba4bacc01982608e5f2739cd394c92809684b102dbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / yapic.di-2.0.12-cp37-cp37m-macosx_10_9_x86_64.whl

Download URL yapic.di-2.0.12-cp37-cp37m-macosx_10_9_x86_64.whl
Size 52.3 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
f74b8ee8c182775b4f69528e51fc9af6f962cf8b2cbd41d65ede687f249551d7
BLAKE2b-256 checksum
How to use checksums
2b29384e8974cd011472ca50ab7c0e459c67b063039fa173c85797341943d1f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Security for yapic.di 2.0.12

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.

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