
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Features:
This library is freely inspired by .NET Standard
Microsoft.Extensions.DependencyInjection
implementation (ref. MSDN,
Dependency injection in ASP.NET
Core,
Using dependency injection in a .Net Core console
application).
The ContainerProtocol
for v2 is inspired by punq.
Rodi is documented here: https://www.neoteroi.dev/rodi/.
pip install rodi
rodi
works by inspecting code once at runtime, to generate
functions that return instances of desired types - as long as the object graph
is not altered. Inspections are done either on constructors
(__init__) or class annotations. Validation steps, for
example to detect circular dependencies or missing services, are done when
building these functions, so additional validation is not needed when
activating services.
rodi
offers two code APIs:
ContainerProtocol
for scenarios
in which it is desirable being able to replace rodi
with alternative
implementations of dependency injection for Python. The protocol only expects
a class being able to register
and resolve
types, and to tell if a type
is configured in it (__contains__
). Even if other implementations of DI
don´t implement these three methods, it should be easy to use
composition to
wrap other libraries with a compatible class.For this reason, the examples report two ways to achieve certain things.
For examples, refer to the examples folder.
All services should be configured once, when an application starts, and the
object graph should not be altered during normal program execution.
Example: if you build a web application, configure the object graph when
bootstrapping the application, avoid altering the Container
configuration
while handling web requests.
Aim at keeping the Container
and service graphs abstracted from the front-end
layer of your application, and avoid mixing runtime values with container
configuration. Example: if you build a web application, avoid if possible
relying on the HTTP Request object being a service registered in your container.
rodi
is used in the BlackSheep
web framework to implement dependency injection for
request handlers.
FAQs
Implementation of dependency injection for Python 3
We found that rodi 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
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.