reagento/dishka ? reverse-engineered prompt

Reverse engineered prompt

Build me a small but polished Python dependency injection library that feels easy to use and actually helpful in real projects.

I want a container where I can register classes and factory functions, then ask for objects by type and have their dependencies filled in automatically from type hints. It should support app level and request level lifetimes, so some things are created once and reused, while others are recreated inside a context manager and cleaned up when that scope ends.

Please include support for finalizers, so things like database connections can be closed automatically. I also want a clean API for grouping providers into separate modules or classes, and the ability to map an implementation to an interface or protocol.

Make it work with normal Python code, keep it lightweight, and include a few examples and tests showing the basic flow, scoped usage, and cleanup. If you need to check anything, look up the current docs online first.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab