ets-labs / python-dependency-injector

Dependency injection framework for Python
https://python-dependency-injector.ets-labs.org/
BSD 3-Clause "New" or "Revised" License
3.89k stars 304 forks source link

Container dependencies issue, multiple files, classes #655

Open Spenchik opened 1 year ago

Spenchik commented 1 year ago

Traceback (most recent call last): File "", line 1178, in _find_and_load File "", line 1149, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "D:\Projects\python\user-test\user\route\user_route.py", line 17, in @user_router.get( ^^^^^^^^^^^^^^^^ File "C:\Users\Eugene\AppData\Local\Programs\Python\Python311\Lib\site-packages\fastapi\routing.py", line 630, in decorator self.add_api_route( File "C:\Users\Eugene\AppData\Local\Programs\Python\Python311\Lib\site-packages\fastapi\routing.py", line 569, in add_api_route route = route_class( ^^^^^^^^^^^^ File "C:\Users\Eugene\AppData\Local\Programs\Python\Python311\Lib\site-packages\fastapi\routing.py", line 442, in init get_parameterless_sub_dependant(depends=depends, path=self.path_format), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Eugene\AppData\Local\Programs\Python\Python311\Lib\site-packages\fastapi\dependencies\utils.py", line 135, in get_parameterless_sub_dependant return get_sub_dependant(depends=depends, dependency=depends.dependency, path=path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Eugene\AppData\Local\Programs\Python\Python311\Lib\site-packages\fastapi\dependencies\utils.py", line 158, in get_sub_dependant sub_dependant = get_dependant( ^^^^^^^^^^^^^^ File "C:\Users\Eugene\AppData\Local\Programs\Python\Python311\Lib\site-packages\fastapi\dependencies\utils.py", line 281, in get_dependant endpoint_signature = get_typed_signature(call) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Eugene\AppData\Local\Programs\Python\Python311\Lib\site-packages\fastapi\dependencies\utils.py", line 249, in get_typed_signature signature = inspect.signature(call) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Eugene\AppData\Local\Programs\Python\Python311\Lib\inspect.py", line 3278, in signature return Signature.from_callable(obj, follow_wrapped=follow_wrapped, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Eugene\AppData\Local\Programs\Python\Python311\Lib\inspect.py", line 3026, in from_callable return _signature_from_callable(obj, sigcls=cls, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Eugene\AppData\Local\Programs\Python\Python311\Lib\inspect.py", line 2615, in _signature_from_callable raise ValueError('callable {!r} is not supported by signature'.format(obj)) ValueError: callable <dependency_injector.providers.Factory(<class 'user.infrastructure.query.user_uow.UserUnitOfWork'>) at 0x27549c2cc40> is not supported by signature python-BaseException

Spenchik commented 1 year ago

Project based on sample from internet, but with async db mysql https://github.com/NEONKID/python-mf-data-example/blob/b226e39aa6e27e58a7fdf8b8baedca476b3c94ac/fastapi_advanced/src/containers.py