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

Basic example not working #38

Open
daaa57150 opened this issue May 20, 2019 · 0 comments
Open

Basic example not working #38

daaa57150 opened this issue May 20, 2019 · 0 comments

Comments

@daaa57150
Copy link

Hi,

I'm really struggling with pinject, even the basic example isn't working for me.
I'm on Windows 10 with python 3.7.3, pinject 0.12.6

My first try resulted in an exception:
ModuleNotFoundError: No module named '_gdbm'

So I applied a workaround I found in issue #22

Now this simple code:

class OuterClass(object):
    def __init__(self, inner_class):
        self.inner_class = inner_class

class InnerClass(object):
    def __init__(self):
        self.forty_two = 42

# somewhere else in my code:
obj_graph = pinject.new_object_graph(
    modules=[core, api]  # workaround
)
outer_class = obj_graph.provide(OuterClass)

Raises this exception:
{NothingInjectableForArgError} when injecting OuterClass.__init__ at C:\Users\me\PycharmProjects\MyProject\api\views.py:32, nothing injectable for the binding name "inner_class" (unannotated)

I even tried to add this line before requesting the outer_class:

inner_class = obj_graph.provide(InnerClass)

It knows how to create it! pinject should now inject that instance to create the outer_class, but it doesn't.

Any idea?

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