
Security News
NVD Quietly Sweeps 100K+ CVEs Into a “Deferred” Black Hole
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
Depinj is a python dependency injection library based on type annotations, it allow's you to define members of a class, and if the type of those members are in the dependency injection system it will be injected once that is called. For example
import depinj
import random
class RandomNumber:
rnumber = random.random()
class TestClass:
rnumber: RandomNumber
depinj.add_scoped(RandomNumber)
depinj.add_scoped(TestClass)
test_class = depinj.get_scoped(TestClass)
The test_class variable will have an scoped RandomNumber instance, there is support for singletons to, with the function add_singleton.
There is an inject decorator that inject's the dependencies into function objects, for example following the previous code:
import depinj
@depinj.inject
def print_number(rn: RandomNumber):
print(rn.rnumber)
print_number()
It can also be used in the init method like this:
class TestClass:
rnumber: RandomNumber
@pydep.inject
def __init__(self, rnumber: RandomNumber):
self.rnumber = rnumber
test_class = TestClass()
from depinj import Injector
dep = Injector()
dep.add_scoped(SomeClass)
This Injector object represent's the dependency injection system, in fact, the functions defined at top-level module are using a global instance of the Depinj class. This way you can have multiple dependency injection systems if you want to have different classes for each one.
If you are going to use a different Injector object than the global one, then you have pass that object into the inject function with the injector named parameter.
FAQs
A friendly dependency injection package
We found that depinj demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
Research
Security News
Lazarus-linked threat actors expand their npm malware campaign with new RAT loaders, hex obfuscation, and over 5,600 downloads across 11 packages.
Security News
Safari 18.4 adds support for Iterator Helpers and two other TC39 JavaScript features, bringing full cross-browser coverage to key parts of the ECMAScript spec.