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

Can't inject decorated classes, getting pinject.errors.WrongArgTypeError: wrong type for arg cls: expected class but got <decorator> #44

@eblis

Description

@eblis

I have a simple class with a no-op decorator defined and I'm trying to use pinject to instantiate it, but haven't got this to work yet.

Python 3.8
pinject==0.14.1

class Controller:
    def __init__(self, original_instance):
        self.original_instance = original_instance

@Controller
class UsersController:
  pass


users = obj_graph.provide(UsersController)

Trying to run this i get the following error:

example_python-3XnK4UKl\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2019.2.3\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 56103 --file Main.py
pydev debugger: process 33564 is connecting

Connected to pydev debugger (build 192.6817.19)
Traceback (most recent call last):
  File "example_python/Main.py", line 29, in <module>
    users = obj_graph.provide(UsersController)
  File "example_python-3XnK4UKl\lib\site-packages\pinject\object_graph.py", line 193, in provide
    support.verify_class_type(cls, 'cls')
  File "example_python-3XnK4UKl\lib\site-packages\pinject\support.py", line 85, in verify_class_type
    _verify_type(inspect.isclass, elt, arg_name, 'class')
  File "example_python-3XnK4UKl\lib\site-packages\pinject\support.py", line 104, in _verify_type
    raise errors.WrongArgTypeError(
pinject.errors.WrongArgTypeError: wrong type for arg cls: expected class but got Controller

Process finished with exit code 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions