tessl install tessl/pypi-rodi@2.0.0Implementation of dependency injection for Python 3
Agent Success
Agent success rate when using this tile
92%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.06x
Baseline
Agent success rate without this tile
87%
Build a service configuration validator that checks if all required services are properly registered in a dependency injection container before the application starts.
You need to create a validator that reads service dependency requirements from a configuration file and verifies that all necessary services are registered in the DI container. This helps catch missing service registrations early, before runtime errors occur.
The validator should read a JSON configuration file with the following structure:
{
"required_services": [
"DatabaseConnection",
"Logger",
"CacheService",
"EmailService"
]
}Create the following files:
validator.py - Contains the ServiceValidator classvalidator.test.py - Contains test casesThe class should have these methods:
__init__(self, container) - Initialize with a DI containervalidate(self, config_path: str) -> dict - Validate services and return a result dictionaryThe result dictionary should have this structure:
{
"valid": bool, # True if all services are available
"missing": list[str], # List of missing service names (empty if all available)
"checked": int # Number of services checked
}Given a container with Logger and CacheService registered, and a config requiring Logger, CacheService, and EmailService, the validation returns valid=False with missing=["EmailService"] and checked=3 @test
Given a container with all services registered (DatabaseConnection, Logger, CacheService, EmailService), and a config requiring all four, the validation returns valid=True with missing=[] and checked=4 @test
Given an empty container and a config requiring DatabaseConnection and Logger, the validation returns valid=False with missing=["DatabaseConnection", "Logger"] and checked=2 @test
Provides dependency injection container functionality
@generates