nasa / apod-api

Astronomy Picture of the Day API service
Apache License 2.0
819 stars 155 forks source link

BeautifulSoup:4.5.3 raising AttributeError. #101

Open anton-shablyko opened 1 year ago

anton-shablyko commented 1 year ago

It looks like an older version of BeautifulSoup causing the application to crash with the following error

 * Running on http://127.0.0.1:5000
INFO:werkzeug:Press CTRL+C to quit
ERROR:apod.utility:module 'collections' has no attribute 'Callable'
ERROR:application:Internal Service Error :<class 'Exception'> msg:module 'collections' has no attribute 'Callable'
ERROR:application:Service Exception. Msg: <class 'TypeError'>
INFO:werkzeug:127.0.0.1 - - [04/Nov/2022 17:03:02] "GET /v1/apod/?concept_tags=True&date=2015-10-11 HTTP/1.1" 500 -

I ran a quick test on my local machine by installing the version provided in requirements.txt

python3 -m pip install -Iv beautifulsoup4==4.5.3

And running a small snippet:

from bs4 import BeautifulSoup

text = """<body></body>"""
soup = BeautifulSoup(text, 'html.parser')

It returns:

AttributeError: module 'collections' has no attribute 'Callable'

However, the most up-to-date version of bs4 (4.11.1) returns the expected result without raising the exception.

It seems like it can be fixed by just updating the module version in the requirements.txt

It also seems to be related to https://github.com/nasa/apod-api/issues/99