Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

pinject.errors.OnlyInstantiableViaProviderFunctionError:Simple Sample Script but not know how to fix the error #56

Open
o1dcat opened this issue Nov 19, 2020 · 0 comments

Comments

@o1dcat
Copy link

o1dcat commented Nov 19, 2020

[root@localhost ~]# python3
Python 3.6.8 (default, Apr 16 2020, 01:36:27)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.

import pinject
from enum import Enum

class SendKind(Enum):
... text = 't'
... link = 'l'
...
class test(object):
... @pinject.copy_args_to_internal_fields
... def init(self,send_kind):
... pass
... def demo(self):
... print(self._send_kind.text)
...
obj_graph = pinject.new_object_graph()
test_class = obj_graph.provide(test)
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pinject/scoping.py", line 62, in provide
return self._binding_key_to_instance[binding_key]
KeyError: <the binding name "send_kind" (unannotated)>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pinject/object_providers.py", line 51, in provide_from_arg_binding_key
provided = provider_indirection.StripIndirectionIfNeeded(Provide)
File "/usr/local/lib/python3.6/site-packages/pinject/provider_indirections.py", line 26, in StripIndirectionIfNeeded
return provide_fn()
File "/usr/local/lib/python3.6/site-packages/pinject/object_providers.py", line 43, in Provide
lambda: binding.proviser_fn(child_injection_context, self,
File "/usr/local/lib/python3.6/site-packages/pinject/scoping.py", line 64, in provide
instance = default_provider_fn()
File "/usr/local/lib/python3.6/site-packages/pinject/object_providers.py", line 44, in
pargs, kwargs))
File "/usr/local/lib/python3.6/site-packages/pinject/bindings.py", line 264, in Proviser
to_class, injection_context, pargs, kwargs)
File "/usr/local/lib/python3.6/site-packages/pinject/object_providers.py", line 70, in provide_class
return cls(*init_pargs, **init_kwargs)
TypeError: call() missing 1 required positional argument: 'value'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.6/site-packages/pinject/object_graph.py", line 203, in provide
raise e
File "/usr/local/lib/python3.6/site-packages/pinject/object_graph.py", line 200, in provide
direct_init_pargs=[], direct_init_kwargs={})
File "/usr/local/lib/python3.6/site-packages/pinject/object_providers.py", line 66, in provide_class
direct_init_pargs, direct_init_kwargs)
File "/usr/local/lib/python3.6/site-packages/pinject/object_providers.py", line 83, in get_injection_pargs_kwargs
lambda abk: self.provide_from_arg_binding_key(
File "/usr/local/lib/python3.6/site-packages/pinject/arg_binding_keys.py", line 108, in create_kwargs
for arg_binding_key in arg_binding_keys}
File "/usr/local/lib/python3.6/site-packages/pinject/arg_binding_keys.py", line 108, in
for arg_binding_key in arg_binding_keys}
File "/usr/local/lib/python3.6/site-packages/pinject/object_providers.py", line 84, in
fn, abk, injection_context))
File "/usr/local/lib/python3.6/site-packages/pinject/object_providers.py", line 58, in provide_from_arg_binding_key
binding.get_binding_target_desc_fn())
pinject.errors.OnlyInstantiableViaProviderFunctionError: when injecting test.init, the arg named "send_kind" unannotated cannot be injected, because its provider, the class main.SendKind, needs at least one directly passed arg

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant