kodemore / kink

Dependency injection container made for Python
MIT License
397 stars 25 forks source link

Don't resolve passed parameters #63

Open aikidojohn opened 3 weeks ago

aikidojohn commented 3 weeks ago

When parameters are partially specified by the caller, parameter resolution happens for all parameters, including the passed in parameters. This can cause some unexpected behavior if the construction of the parameter is expensive or has side-effects.

I ran into this issue when introducing Kink into a complex project with a large unit test suit. The unit tests would pass in mock objects, but Kink would try to resolve them anyway, sometimes resulting in unexpected side-effects and errors.

This change will skip parameter resolution for parameters that were passed in by the caller.

** Maintainers - I am new to the Kink codebase. If there is a better way/place to make this change, I am happy to take feedback and see this change through.