Compatibility issue with Python < 3.9 due to type hinting
DiscordChatExporterPy Version
2.7.0
Discord Version
Pycord 2.5.0
Bug Description
Hi.
Trying to run Pycord bot with the 2.7.0 version of chat_exporter results in the below error:
File "C:\Users\laiye\.conda\envs\dvbot\lib\site-packages\chat_exporter\ext\cache.py", line 27, in decorator
def _make_key(args: tuple[Any, ...], kwargs: dict[str, Any]) -> str:
TypeError: 'type' object is not subscriptable
This error seems to stem from the type hinting used in chat_exporter/ext/cache.py, specifically with tuple and dict.
In Python versions older than 3.9, subscript notation for built-in types without importing from the typing module (like Dict, Tuple) isn't supported. I was using Python 3.8.15.
PR #101 imports Dict and Tuple from typing, allowing this library to support versions older than 3.9.
Bug Traceback
.conda\envs\dvbot\python.exe PycharmProjects\dank-vibes-bot\main.py
Traceback (most recent call last):
File ".conda\envs\dvbot\lib\site-packages\discord\cog.py", line 778, in _load_from_module_spec
spec.loader.exec_module(lib) # type: ignore
File "<frozen importlib._bootstrap_external>", line 843, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "PycharmProjects\dank-vibes-bot\cogs\dev\__init__.py", line 1, in <module>
from .dev import Developer
File "PycharmProjects\dank-vibes-bot\cogs\dev\dev.py", line 17, in <module>
import chat_exporter
File ".conda\envs\dvbot\lib\site-packages\chat_exporter\__init__.py", line 1, in <module>
from chat_exporter.chat_exporter import (
File ".conda\envs\dvbot\lib\site-packages\chat_exporter\chat_exporter.py", line 5, in <module>
from chat_exporter.construct.transcript import Transcript
File ".conda\envs\dvbot\lib\site-packages\chat_exporter\construct\transcript.py", line 13, in <module>
from chat_exporter.construct.message import gather_messages
File ".conda\envs\dvbot\lib\site-packages\chat_exporter\construct\message.py", line 13, in <module>
from chat_exporter.construct.assets import Attachment, Component, Embed, Reaction
File ".conda\envs\dvbot\lib\site-packages\chat_exporter\construct\assets\__init__.py", line 1, in <module>
from .embed import Embed
File ".conda\envs\dvbot\lib\site-packages\chat_exporter\construct\assets\embed.py", line 5, in <module>
from chat_exporter.ext.html_generator import (
File ".conda\envs\dvbot\lib\site-packages\chat_exporter\ext\html_generator.py", line 3, in <module>
from chat_exporter.parse.mention import ParseMention
File ".conda\envs\dvbot\lib\site-packages\chat_exporter\parse\mention.py", line 9, in <module>
from chat_exporter.parse.markdown import ParseMarkdown
File ".conda\envs\dvbot\lib\site-packages\chat_exporter\parse\markdown.py", line 3, in <module>
from chat_exporter.ext.emoji_convert import convert_emoji
File ".conda\envs\dvbot\lib\site-packages\chat_exporter\ext\emoji_convert.py", line 44, in <module>
async def valid_src(src):
File ".conda\envs\dvbot\lib\site-packages\chat_exporter\ext\cache.py", line 27, in decorator
def _make_key(args: tuple[Any, ...], kwargs: dict[str, Any]) -> str:
TypeError: 'type' object is not subscriptable
Additional Information
No response
@argo0n eh, I just pushed 2.7.0 and nuked the branch, so it killed your PR - could you create a new pointing to 2.8.0 please? 👀
@argo0n eh, I just pushed
2.7.0and nuked the branch, so it killed your PR - could you create a new pointing to2.8.0please? 👀
@mahtoid done! https://github.com/mahtoid/DiscordChatExporterPy/pull/105
This is now pushed with the latest version, please run pip install --upgrade chat-exporter to get the latest version.
Sorry for the wait! 💜
This is now pushed with the latest version, please run
pip install --upgrade chat-exporterto get the latest version.Sorry for the wait! 💜
No problem. Thanks for creating such a useful library!