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

Cannot wire module with queue.Queue #362

Closed
ventaquil opened this issue Jan 18, 2021 · 4 comments
Closed

Cannot wire module with queue.Queue #362

ventaquil opened this issue Jan 18, 2021 · 4 comments
Assignees
Labels

Comments

@ventaquil
Copy link

Wiring any module which imports queue.Queue raises error ValueError: no signature found for builtin type <class 'types.GenericAlias'>.

Traceback (most recent call last):
  File "/home/ventaquil/Git/project/package/__main__.py", line 86, in <module>
    sys.exit(main())
  File "/home/ventaquil/Git/project/package/__main__.py", line 67, in main
    container.wire(modules=[http, manager, socketio], packages=[model])
  File "src/dependency_injector/containers.pyx", line 222, in dependency_injector.containers.DynamicContainer.wire
  File "/home/ventaquil/Git/project/cluster/venv/lib/python3.9/site-packages/dependency_injector/wiring.py", line 230, in wire
    _patch_method(member, method_name, method, providers_map)
  File "/home/ventaquil/Git/project/venv/lib/python3.9/site-packages/dependency_injector/wiring.py", line 302, in _patch_method
    reference_injections, reference_closing = _fetch_reference_injections(fn)
  File "/home/ventaquil/Git/project/venv/lib/python3.9/site-packages/dependency_injector/wiring.py", line 336, in _fetch_reference_injections
    signature = inspect.signature(fn)
  File "/usr/lib/python3.9/inspect.py", line 3118, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
  File "/usr/lib/python3.9/inspect.py", line 2867, in from_callable
    return _signature_from_callable(obj, sigcls=cls,
  File "/usr/lib/python3.9/inspect.py", line 2398, in _signature_from_callable
    raise ValueError(
ValueError: no signature found for builtin type <class 'types.GenericAlias'>
@rmk135 rmk135 self-assigned this Jan 18, 2021
@rmk135 rmk135 added the bug label Jan 18, 2021
@rmk135
Copy link
Member

rmk135 commented Jan 18, 2021

Hi @ventaquil , thanks for reporting the bug. That's serious stuff, will take a look.

@ventaquil
Copy link
Author

Hey @rmk135, thanks for response. I have tried quick fix with try...catch block but it's not enough.

@rmk135
Copy link
Member

rmk135 commented Jan 19, 2021

Fixed in 4.10.1.

Looks like it was a Python 3.9 specific problem. Introspection doesn't work for types.GenericAlias. It is used as queue.Queue.__class_getitem__() method:

>>> import inspect
>>> import queue
>>>
>>> inspect.signature(queue.Queue.__class_getitem__)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/python@3.9/3.9.1_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 3130, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
  File "/usr/local/Cellar/python@3.9/3.9.1_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 2879, in from_callable
    return _signature_from_callable(obj, sigcls=cls,
  File "/usr/local/Cellar/python@3.9/3.9.1_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 2259, in _signature_from_callable
    sig = _signature_from_callable(
  File "/usr/local/Cellar/python@3.9/3.9.1_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 2410, in _signature_from_callable
    raise ValueError(
ValueError: no signature found for builtin type <class 'types.GenericAlias'>
>>>
>>>
>>> import types
>>> inspect.signature(types.GenericAlias)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/python@3.9/3.9.1_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 3130, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
  File "/usr/local/Cellar/python@3.9/3.9.1_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 2879, in from_callable
    return _signature_from_callable(obj, sigcls=cls,
  File "/usr/local/Cellar/python@3.9/3.9.1_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 2410, in _signature_from_callable
    raise ValueError(
ValueError: no signature found for builtin type <class 'types.GenericAlias'>

Thanks a lot for reporting the bug @ventaquil . Closing the issue, reopen if needed.

@rmk135 rmk135 closed this as completed Jan 19, 2021
@ventaquil
Copy link
Author

Works perfect! Thank you very much for such quick fix 👍

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