bellingcat / auto-archiver

Automatically archive links to videos, images, and social media content from Google Sheets (and more).
https://pypi.org/project/auto-archiver/
MIT License
578 stars 60 forks source link

Python versions below 3.10 not supported #146

Closed ADarkDividedGem closed 3 months ago

ADarkDividedGem commented 4 months ago

I am using Python 3.9.13 and ran into the following error when I run auto-archiver --help

auto-archiver --help Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\Dave\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\auto-archiver.exe\main__.py", line 4, in from auto_archiver.main import main File "C:\Users\Dave\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\auto_archiver\init.py", line 1, in from . import archivers, databases, enrichers, feeders, formatters, storages, utils, core File "C:\Users\Dave\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\auto_archiver\archivers\init__.py", line 3, in from .twitter_archiver import TwitterArchiver File "C:\Users\Dave\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\auto_archiver\archivers\twitter_archiver.py", line 15, in class TwitterArchiver(Archiver): File "C:\Users\Dave\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\auto_archiver\archivers\twitter_archiver.py", line 65, in TwitterArchiver def download_snscrape(self, item: Metadata, url: str, tweet_id: str) -> Union[Metadata|bool]: TypeError: unsupported operand type(s) for |: 'type' and 'type'

This happens because union types are only support in Python 3.10: https://peps.python.org/pep-0604/

To get round the issue I added from __future__ import annotations to the top of the twitter_archiver.py file. https://github.com/tiangolo/typer/issues/371#issuecomment-1073695552

Given your readme asks that "python 3.8 or higher" is installed I thought I would report this bug.

msramalho commented 3 months ago

Hey @ADarkDividedGem I've had a look at this and there are indeed several uses of the union notation for types across the project. While changing them could be a quick fix I suspect there may be other issues with python 3.8 namely in dependencies as this project has been mostly developed with python 3.10.

As such, I'll update the min version of the project to 3.10 for now, since having the support means always testing with 3.8 and we're not doing that atm. The ideal future scenario will be a set of CI tests that run on multiple python versions and would allow us to expand to support older versions too.

Thanks for noticing and adding good reference materials.