
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
A lightweight dependency injection framework for Python inspired by the Symfony Framework.
pip install dimwiddle
Or install from the repository:
git clone https://github.com/whittlelabs/dimwiddle.git
cd dimwiddle
pip install -e .
Create a services.yaml
file:
services:
# Basic service
greeting:
class: myapp.services.greeting_service.GreetingService
arguments: ["Hello, %USER_NAME%!"]
# Service with dependency
greeter:
class: myapp.services.greeter.Greeter
arguments: ["@greeting"]
# myapp/services/greeting_service.py
class GreetingService:
def __init__(self, greeting_format):
self.greeting_format = greeting_format
def greet(self, name):
return self.greeting_format.format(name=name)
# myapp/services/greeter.py
class Greeter:
def __init__(self, greeting_service):
self.greeting_service = greeting_service
def greet_user(self, user):
return self.greeting_service.greet(user)
from dimwiddle.application.load_definitions import create_container_from_yaml
from dimwiddle.infrastructure.config import EnvConfig
# Create a container with environment variables
config = EnvConfig(dotenv_path=".env")
container = create_container_from_yaml("services.yaml", config=config)
# Get a service
greeter = container.get("greeter")
print(greeter.greet_user("World")) # Hello, World!
Services are defined in YAML with the following properties:
class
: The fully qualified class namearguments
: List (positional) or dict (named) of constructor argumentsfactory
: A two-element list: service reference and method nametags
: List of tags to categorize this serviceinject_class
: If true, inject the class itself instead of an instanceDimwiddle supports special syntax in service arguments:
@service_name
: Reference to another service%ENV_VAR%
: Reference to an environment variable!tagged_iterator { tag: tag_name, index_by: property }
: Collection of services with a tag~path/to/file.yaml:subpath.to.value
: Reference to a value in another YAML fileThe library uses an abstract configuration provider that can be implemented in different ways:
from dimwiddle.infrastructure.config import EnvConfig, DictConfig
# Load configuration from environment variables and .env file
config = EnvConfig(dotenv_path=".env")
# Or use a dictionary for configuration
config = DictConfig({
"API_KEY": "my-api-key",
"DEBUG": "true"
})
Dimwiddle is designed to be easily testable. You can create test containers with mock services:
from dimwiddle.domain.container import Container
from dimwiddle.domain.service_definition import ServiceDefinition
# Create mock services
definitions = {
"mock_service": ServiceDefinition(
cls=MockService,
pos_args=["test value"]
)
}
# Create container with mocks
container = Container(definitions)
See the examples
directory for complete working examples, including:
MIT
FAQs
A lightweight dependency injection framework inspired by Symfony
We found that dimwiddle 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
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.