recent push to main causing dynamic type run time exception
lb-ronyeh opened this issue · 1 comments
lb-ronyeh commented
i tried to pip install
git+https://github.com/long2ice/fastapi-cache@main
just to get recent fixes i.e #130, but now im getting :
Traceback (most recent call last):
2023-05-12T12:26:22.626188184Z File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2023-05-12T12:26:22.626192435Z worker.init_process()
2023-05-12T12:26:22.626196198Z File "/usr/local/lib/python3.9/site-packages/uvicorn/workers.py", line 66, in init_process
2023-05-12T12:26:22.626204291Z super(UvicornWorker, self).init_process()
2023-05-12T12:26:22.626213158Z File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process
2023-05-12T12:26:22.626223935Z self.load_wsgi()
2023-05-12T12:26:22.626231434Z File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2023-05-12T12:26:22.626235836Z self.wsgi = self.app.wsgi()
2023-05-12T12:26:22.626239598Z File "/usr/local/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
2023-05-12T12:26:22.626243448Z self.callable = self.load()
2023-05-12T12:26:22.626246665Z File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2023-05-12T12:26:22.626249737Z return self.load_wsgiapp()
2023-05-12T12:26:22.626252958Z File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2023-05-12T12:26:22.626256217Z return util.import_app(self.app_uri)
2023-05-12T12:26:22.626259812Z File "/usr/local/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app
2023-05-12T12:26:22.626263314Z mod = importlib.import_module(module)
2023-05-12T12:26:22.626266496Z File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
2023-05-12T12:26:22.626269894Z return _bootstrap._gcd_import(name[level:], package, level)
2023-05-12T12:26:22.626273208Z File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2023-05-12T12:26:22.626276854Z File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2023-05-12T12:26:22.626280547Z File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
2023-05-12T12:26:22.626283933Z File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
2023-05-12T12:26:22.626287763Z File "<frozen importlib._bootstrap_external>", line 850, in exec_module
2023-05-12T12:26:22.626291526Z File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
2023-05-12T12:26:22.626309268Z File "/app/pdt_api/main.py", line 15, in <module>
2023-05-12T12:26:22.626314175Z from fastapi_cache.backends.redis import RedisBackend
2023-05-12T12:26:22.626317885Z File "/usr/local/lib/python3.9/site-packages/fastapi_cache/backends/redis.py", line 9, in <module>
2023-05-12T12:26:22.626321578Z class RedisBackend(Backend):
2023-05-12T12:26:22.626326465Z File "/usr/local/lib/python3.9/site-packages/fastapi_cache/backends/redis.py", line 10, in RedisBackend
2023-05-12T12:26:22.626330423Z def __init__(self, redis: Union[Redis[bytes], RedisCluster[bytes]]):
2023-05-12T12:26:22.626333840Z File "/usr/local/lib/python3.9/typing.py", line 277, in inner
2023-05-12T12:26:22.626337369Z return func(*args, **kwds)
2023-05-12T12:26:22.626340609Z File "/usr/local/lib/python3.9/typing.py", line 1004, in __class_getitem__
2023-05-12T12:26:22.626343921Z _check_generic(cls, params, len(cls.__parameters__))
2023-05-12T12:26:22.626347210Z File "/usr/local/lib/python3.9/site-packages/typing_extensions.py", line 97, in _check_generic
2023-05-12T12:26:22.626350839Z raise TypeError(f"{cls} is not a generic class")
2023-05-12T12:26:22.626354290Z TypeError: <class 'redis.asyncio.client.Redis'> is not a generic class
might be related
python/typeshed#8242 (comment)
im using
gunicorn==20.1.0
uvicorn==0.22.0
fastapi==0.95.1
mjpieters commented
Darn, I would have hoped that the mypy checks would have caught this. Unfortunately, the type checker doesn't check for __class_getitem__
support here.
And, since the backend modules are not being imported anywhere, running the tests also never validates these annotations :-( I'll give it a think and create a PR.