Skip to content
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

Creating a provider of ABC #266

Closed
awaizman1 opened this issue Jul 22, 2020 · 3 comments
Closed

Creating a provider of ABC #266

awaizman1 opened this issue Jul 22, 2020 · 3 comments
Assignees
Labels

Comments

@awaizman1
Copy link

@awaizman1 awaizman1 commented Jul 22, 2020

Hi,

I'm trying to create a Dependency provider for some python interface I have in the form of abstract-base-class (ABC).
Trying creating the provider raises an error.
What is the correct way for achieving this?

# file testc.py

from abc import ABC

from dependency_injector import providers

class Base(ABC):
    pass

class Impl(Base):
    pass

p = providers.Dependency(Base)  # this line raises
p.provided_by(providers.Object(Impl()))

I get the following error:

Traceback (most recent call last):
  File "testc.py", line 13, in <module>
    p = providers.Dependency(Base)
TypeError: Argument 'instance_of' has incorrect type (expected type, got ABCMeta)

Thanks

@rmk135 rmk135 self-assigned this Jul 22, 2020
@rmk135 rmk135 added the bug label Jul 22, 2020
@rmk135
Copy link
Member

@rmk135 rmk135 commented Jul 22, 2020

Hi @awaizman1 ,

That's a bug. It's easy to fix. Expect a fixed version on a couple of hours.

Roman

@awaizman1
Copy link
Author

@awaizman1 awaizman1 commented Jul 22, 2020

Thanks

appreciate it

@rmk135
Copy link
Member

@rmk135 rmk135 commented Jul 22, 2020

Fixed in 3.23.1. It's already on the PyPI. You're welcome to upgrade.

Thanks for raising the issue.

Roman

@rmk135 rmk135 closed this as completed Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants