Just-Some-Bots / MusicBot

:musical_note: The original MusicBot for Discord (formerly SexualRhinoceros/MusicBot)
https://just-some-bots.github.io/MusicBot/
MIT License
3.09k stars 2.35k forks source link

New caching code doesn't work on Python 3.8 #2368

Closed phknot closed 6 months ago

phknot commented 7 months ago

What went wrong?

The new code introduced with https://github.com/Just-Some-Bots/MusicBot/pull/2365 uses arrow notation in function definitions, which is only supported since Python 3.9.

This project advertises a minimum version of 3.8 to function. I suggest either modifying the code to work on Python 3.8, or updating the whole project to 3.9

How do we reproduce this?

Try running the bot with Python 3.8, for example with the Docker image. It will give an error.

Which version of the bot are you using?

None

Which operating system are you using?

None

Just checking...

itsTheFae commented 7 months ago

So I checked the docs and they seem to indicate that type hinting with arrows was added in 3.5: https://docs.python.org/3.8/library/typing.html

Do you mind documenting what OS you're on, and posting a copy of the error log for us to review? Thanks.

phknot commented 6 months ago

So I checked the docs and they seem to indicate that type hinting with arrows was added in 3.5: https://docs.python.org/3.8/library/typing.html

Type hinting on collections was added in 3.9 https://docs.python.org/release/3.9.0/whatsnew/3.9.html#type-hinting-generics-in-standard-collections

Do you mind documenting what OS you're on, and posting a copy of the error log for us to review? Thanks.

I run the bot using the provided docker setup. When trying to start you'll get the following error:

musicbot-musicbot-1  | [ERROR] launcher: Error starting bot
musicbot-musicbot-1  | Traceback (most recent call last):
musicbot-musicbot-1  |   File "run.py", line 409, in main
musicbot-musicbot-1  |     from musicbot import MusicBot
musicbot-musicbot-1  |   File "/musicbot/musicbot/__init__.py", line 4, in <module>
musicbot-musicbot-1  |     from .bot import MusicBot
musicbot-musicbot-1  |   File "/musicbot/musicbot/bot.py", line 33, in <module>
musicbot-musicbot-1  |     from .filecache import AudioFileCache
musicbot-musicbot-1  |   File "/musicbot/musicbot/filecache.py", line 19, in <module>
musicbot-musicbot-1  |     class AudioFileCache:
musicbot-musicbot-1  |   File "/musicbot/musicbot/filecache.py", line 40, in AudioFileCache
musicbot-musicbot-1  |     def get_cache_size(self) -> tuple[int, int]:
musicbot-musicbot-1  | TypeError: 'type' object is not subscriptable
musicbot-musicbot-1  |
musicbot-musicbot-1  | [INFO] launcher: All done.
musicbot-musicbot-1 exited with code 0

I have already made a pull requests where I've updated the whole project to 3.9 or newer when possible. I think that's a good idea anyway, just to stay up-to-date with the latest improvements and prevent future work.

edit: had the wrong link for collection type hints