ncraike / fang

Dependency injection system for Python
MIT License
15 stars 1 forks source link

Dependencies seem to be evaluated at resolve time instead of being a callable resource #14

Open traveaston opened 4 years ago

traveaston commented 4 years ago

My impression of the goal of this library is to be able to return the standard dependencies normally in my program, but for testing, replacing those dependencies with fake versions in order to not perform live filesystem calls.

Just using the example (introduction.py), and converting the dependency to a function that returns the multiplier passed to it (dumb & circular but it's for demonstration purposes) gives this traceback

https://github.com/ncraike/fang/blob/2d9e1216c866e450059017f83ab775f7716eda7a/fang/resource_provider_register.py#L69

This line seems to be the issue, where it calls the dependency at resolve time, rather than returning the dependency itself and allowing you to call it whenever and with whatever parameters you like.

Is this by design, or an oversight? Am I misinterpreting/misusing the library?