Skip to content

Auto-bind/resolve only unset/missing bindings #18

@Aegdesil

Description

@Aegdesil

Discussed in #17

Originally posted by evermediocre August 15, 2021
Is there a way to NOT ignore current bindings when auto_bindings=True ?

class A:
    ...

class B:
    def __init__(self, a: A):
        print("a", a)

class X(A):
    ...

i = Injector(
    bindings=[ClassBinding(A, X)],
    options=InjectorOptions(auto_bindings=True)
)

b = i.inject(B)

Output:

a <__main__.A object at 0x0000020DF1469B80> # I expected an instance of X

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions