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

importing fastapi Request object breaks wiring #398

tapm opened this issue Feb 15, 2021 · 3 comments

importing fastapi Request object breaks wiring #398

tapm opened this issue Feb 15, 2021 · 3 comments


Copy link

tapm commented Feb 15, 2021


In the if we replace the line:

from fastapi import FastAPI, Depends


from fastapi import FastAPI, Depends, Request

we get the following stack trace:

File "./", line 29, in <module>                                                                                                                                           
 File "src/dependency_injector/containers.pyx", line 250, in dependency_injector.containers.DynamicContainer.wire
 File ".../python-dependency-injector-master/examples/miniapps/fastapi-simple/venv/lib/python3.9/site-packages/dependency_injector/", line 242, in wire
   _patch_method(member, method_name, method, providers_map)                   
 File ".../python-dependency-injector-master/examples/miniapps/fastapi-simple/venv/lib/python3.9/site-packages/dependency_injector/", line 314, in _patch_method
   reference_injections, reference_closing = _fetch_reference_injections(fn)   
 File ".../python-dependency-injector-master/examples/miniapps/fastapi-simple/venv/lib/python3.9/site-packages/dependency_injector/", line 352, in _fetch_reference_injections
   signature = inspect.signature(fn)                                           
 File "/usr/lib/python3.9/", line 3130, in signature                 
   return Signature.from_callable(obj, follow_wrapped=follow_wrapped)          
 File "/usr/lib/python3.9/", line 2879, in from_callable             
   return _signature_from_callable(obj, sigcls=cls,                            
 File "/usr/lib/python3.9/", line 2259, in _signature_from_callable  
   sig = _signature_from_callable(                                             
 File "/usr/lib/python3.9/", line 2410, in _signature_from_callable  
   raise ValueError(                                                           
ValueError: no signature found for builtin type <class 'types.GenericAlias'>    

Note: fastapi Request object is simply reimported from starlette.

Thanks in advance for your time and props for this great project!

@rmk135 rmk135 self-assigned this Feb 15, 2021
@rmk135 rmk135 added the bug label Feb 15, 2021
Copy link

rmk135 commented Feb 15, 2021

Hi @tapm , this definitely looks like a bug. Thanks for reporting.

Copy link

rmk135 commented Feb 16, 2021

Fixed in 4.23.1. There already was a similar issue #362 . That seems to be a Python 3.9 bug: inspect fails on inspecting types.GenericAlias builtin class. I have added a workaround to avoid the error. Hope this will get fixed in Python in 3.10.

@rmk135 rmk135 closed this as completed Feb 16, 2021
Copy link

tapm commented Feb 16, 2021

Worked like a charm :) Once again, great job! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants