python-dependency-injector
python-dependency-injector copied to clipboard
The example “fastapi-sqlalchemy” cannot be executed ...
hi, I cloned the git-master code and try to run the example without any modification in my miniconda environment where python version is 3.8.11, but the example “fastapi-sqlalchemy” cannot be executed. The error message is "TypeError: 'ABCMeta' object is not subscriptable". related environment is uvicorn 0.15.0 fastapi 0.68.1 dependency-injector 4.36.0
how to fix it ? Thanks !
fastapi-sqlalchemy % python -m webapp.application
Traceback (most recent call last):
File "/Users/zoo/miniconda3/envs/gui/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Users/zoo/miniconda3/envs/gui/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/zoo/Downloads/python-dependency-injector-master/examples/miniapps/fastapi-sqlalchemy/webapp/application.py", line 5, in
Thanks for reporting the issue @hustlmh . After a quick search, I found that adding from __future__ import annotations might help as a workaround. I didn't test it yet. A dirtier but 100% working fix is to just remove type annotations from line 32:
@contextmanager
def session(self) -> Callable[..., AbstractContextManager[Session]]:
I'll also try to see how to make it work on all supported Python versions. Thanks again.
@rmk135 where should this import be set? @hustlmh , did it work for you?