-
-
Notifications
You must be signed in to change notification settings - Fork 343
Add provided()<func>.call *args, **kwargs arguments #945 #946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
ZipFile
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine, but we need test coverage for this new feature.
|
|
||
| @inject | ||
| def test_provided_instance_call_with_args( | ||
| some_value: int = Provide[Container.service_with_callable.provided.method_with_args.call(1, 2)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we test for string ids? I.e. Provide["service_with_callable", provided().method_with_args.call(1, 2)]?
| self.method_with_args = lambda x, y: x + y | ||
| self.method_with_kwargs = lambda **kwargs: kwargs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to have them as proper methods
|
|
||
| class ServiceWithCallable: | ||
| def __init__(self): | ||
| self.foo = CallableDict({"bar": lambda: 10}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| self.foo = CallableDict({"bar": lambda: 10}) | |
| self.foo = {"bar": lambda *args, **kwargs: {"args": args, "kwargs": kwargs}} |
Does it need to be separate dict subclass?
#945