ivankorobkov / python-inject

Python dependency injection
Apache License 2.0
694 stars 79 forks source link

Issue 12 params #13

Closed scharf closed 10 years ago

scharf commented 10 years ago

I added @params to solve the problems in issue ivankorobkov/python-inject#12

@params uses keyword parameters to inject parameters into functions (see unittests)

scharf commented 10 years ago

I have tried to patch the original @param wrapper but the problem is, that it is quite hard to get to the original function (one could use function attributes to pass the original function to the next param) when multiple @param are used. And constructing the position argument tuple, may be quite a challenge, but possible...

ivankorobkov commented 10 years ago

Previous version of python-inject supported positional args via function attrs. However, I never actually used them, so I got rid of them.

I like @inject.params(arg1=cls, arg2=cls2). It is better than @inject.param. I will deprecate the latter.

ivankorobkov commented 10 years ago

Thanks for a good pull-request. I have uploaded a new version to pypi, see https://pypi.python.org/pypi/Inject/3.3.0

scharf commented 10 years ago

Thank you for merging my pull-request. I really like python-inject for of its simplicity.