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

TypeError in __init__ throws OnlyInstantiableViaProviderFunctionError #10

Open
MirkoRossini opened this issue Sep 23, 2014 · 0 comments

Comments

@MirkoRossini
Copy link

Hello,

every time I cause a TypeError in the init method of an injected class, pinject raises a pretty cryptic Exception that makes debugging way harder:

import pinject
class Foo(object):
def init(self, bar):
self.bar = bar

class Bar(object):
def init(self, foo_bar):
self.foo_bar = foo_bar

class FooBar(object):
def init(self):
raise TypeError("test")

o = pinject.new_object_graph()
o.provide(Foo)

Traceback (most recent call last):
File "/tmp/a.py", line 16, in
o.provide(Foo)
File "/spare/local/secmaster-overwatch-infra/lib/python2.7/site-packages/pinject/object_graph.py", line 244, in provide
raise e
pinject.errors.OnlyInstantiableViaProviderFunctionError: when injecting Bar.init at /tmp/a.py:8, the arg named "foo_bar" unannotated cannot be injected, because its provider, the class main.FooBar at /tmp/a.py:11, needs at least one directly passed arg

Thanks

Mirko

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