DiscordChatExporterPy icon indicating copy to clipboard operation
DiscordChatExporterPy copied to clipboard

Compatibility issue with Python < 3.9 due to type hinting

Open argo0n opened this issue 3 months ago • 2 comments

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 avatar Mar 26 '24 08:03 argo0n