-
Notifications
You must be signed in to change notification settings - Fork 81
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
Register classes programmatically #59
Comments
@ivankorobkov in PR #60 I have implemented that possibility. Now it is possible in following way: def configure(binder: Binder):
binder.bind_to_constructor(SomeClass, inject.autoparams()(SomeClass))
inject.configure(configure) |
@ivankorobkov it would be great to have the possibility to use The following test will fail because classes def test_class_support_in_autoparams_decorator(self):
@autoparams()
class AnotherClass:
pass
@autoparams()
class SomeClass:
def __init__(self, another_object: AnotherClass):
self.another_object = another_object
inject.configure()
some_object = inject.instance(SomeClass)
assert isinstance(some_object, SomeClass)
assert isinstance(some_object.another_object, AnotherClass) To properly solve this issue we should return child class of |
Add support for classes in autoparams (#59)
Is it possible to register classes in the same way as
@inject.autoparams
provides but programmatically inside configuration callback?For example:
This example will throw an error:
The text was updated successfully, but these errors were encountered: