calpaterson / csvbase

a simple website for sharing table data - with an API
https://csvbase.com
GNU Affero General Public License v3.0
376 stars 13 forks source link

Remove PEP 585-style type hints for compatibility with Python<3.9 #139

Closed andybearman closed 2 months ago

andybearman commented 2 months ago

I think this makes sense as the Dockerfile is using the 3.8 base image. Alternatively, we could update it to use 3.9 and drop support for 3.8 altogether.

$ docker compose logs csvbase
csvbase-1  | [2024-09-12 17:46:56 +0000] [7] [INFO] Starting gunicorn 22.0.0
csvbase-1  | [2024-09-12 17:46:56 +0000] [7] [INFO] Listening at: http://0.0.0.0:6001 (7)
csvbase-1  | [2024-09-12 17:46:56 +0000] [7] [INFO] Using worker: sync
csvbase-1  | [2024-09-12 17:46:56 +0000] [9] [INFO] Booting worker with pid: 9
csvbase-1  | [2024-09-12 17:46:56 +0000] [9] [ERROR] Exception in worker process
csvbase-1  | Traceback (most recent call last):
csvbase-1  |   File "/usr/local/lib/python3.8/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
csvbase-1  |     worker.init_process()
csvbase-1  |   File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
csvbase-1  |     self.load_wsgi()
csvbase-1  |   File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
csvbase-1  |     self.wsgi = self.app.wsgi()
csvbase-1  |   File "/usr/local/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
csvbase-1  |     self.callable = self.load()
csvbase-1  |   File "/usr/local/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
csvbase-1  |     return self.load_wsgiapp()
csvbase-1  |   File "/usr/local/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
csvbase-1  |     return util.import_app(self.app_uri)
csvbase-1  |   File "/usr/local/lib/python3.8/site-packages/gunicorn/util.py", line 371, in import_app
csvbase-1  |     mod = importlib.import_module(module)
csvbase-1  |   File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
csvbase-1  |     return _bootstrap._gcd_import(name[level:], package, level)
csvbase-1  |   File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
csvbase-1  |   File "<frozen importlib._bootstrap>", line 991, in _find_and_load
csvbase-1  |   File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
csvbase-1  |   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
csvbase-1  |   File "<frozen importlib._bootstrap_external>", line 843, in exec_module
csvbase-1  |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
csvbase-1  |   File "/usr/local/lib/python3.8/site-packages/csvbase/web/app.py", line 40, in <module>
csvbase-1  |     from .blog.bp import bp as blog_bp
csvbase-1  |   File "/usr/local/lib/python3.8/site-packages/csvbase/web/blog/bp.py", line 12, in <module>
csvbase-1  |     from csvbase.markdown import render_markdown
csvbase-1  |   File "/usr/local/lib/python3.8/site-packages/csvbase/markdown.py", line 99, in <module>
csvbase-1  |     def extract_references(md_str: str) -> list[str]:
csvbase-1  | TypeError: 'type' object is not subscriptable
csvbase-1  | [2024-09-12 17:46:56 +0000] [9] [INFO] Worker exiting (pid: 9)
csvbase-1  | [2024-09-12 17:46:56 +0000] [7] [ERROR] Worker (pid:9) exited with code 3
csvbase-1  | [2024-09-12 17:46:56 +0000] [7] [ERROR] Shutting down: Master
csvbase-1  | [2024-09-12 17:46:56 +0000] [7] [ERROR] Reason: Worker failed to boot.
calpaterson commented 2 months ago

Thanks! Though for what it's worth it really runs on 3.9 right now (debian bullseye) and i want to move to 3.12 soon (new ubuntu LTS)