question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't start bot when using Jishaku 2.5.0

See original GitHub issue

Summary

After upgrading my Production and Development instances of the Jishaku library to the latest version (whether that be v2.5.0 itself or using the latest master branch version), I am no longer able to start my bots because of an error relating to typing violations. The error is given below in the actual results section.

My theory is that this latest version of Jishaku seems to be using features that might be requiring Python 3.10 and is no longer compatible with anything older than this version, but which is not mentioned anywhere or even specified in the requirements files, implying that Jishaku 2.5 is intended to be supported on Python 3.8 or newer.

Reproduction steps

  1. Install Python 3.8.5 or Python 3.9.6
  2. Install Jishaku 2.5.0 or latest master branch via appropriate pip commands.
  3. Load jishaku by calling await bot.load_extension("jishaku") in your code.
  4. Start the bot.

Expected results

The extension gets loaded and it can be used by the bot.

Actual results

Bot won’t start, error trace is given below [account names are redacted]. This doesn’t occur on Jishaku 2.4.0, so I have had to keep myself rolled back on this version to allow my bots to start while keeping the library loaded:

May 15 17:06:02 [REDACTED] python3.9[31368]: An error has been found trying to load the extension jishaku:
May 15 17:06:02 [REDACTED] python3.9[31368]: Traceback (most recent call last):
May 15 17:06:02 [REDACTED] python3.9[31368]: File "/usr/local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 916, in _load_from_module_spec
May 15 17:06:02 [REDACTED] python3.9[31368]: spec.loader.exec_module(lib)  # type: ignore
May 15 17:06:02 [REDACTED] python3.9[31368]: File "<frozen importlib._bootstrap_external>", line 850, in exec_module
May 15 17:06:02 [REDACTED] python3.9[31368]: File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
May 15 17:06:02 [REDACTED] python3.9[31368]: File "/usr/local/lib/python3.9/site-packages/jishaku/__init__.py", line 15, in <module>
May 15 17:06:02 [REDACTED] python3.9[31368]: from jishaku.cog import *  # noqa: F401
May 15 17:06:02 [REDACTED] python3.9[31368]: File "/usr/local/lib/python3.9/site-packages/jishaku/cog.py", line 19, in <module>
May 15 17:06:02 [REDACTED] python3.9[31368]: from jishaku.features.baseclass import Feature
May 15 17:06:02 [REDACTED] python3.9[31368]: File "/usr/local/lib/python3.9/site-packages/jishaku/features/baseclass.py", line 79, in <module>
May 15 17:06:02 [REDACTED] python3.9[31368]: class Feature(commands.Cog):
May 15 17:06:02 [REDACTED] python3.9[31368]: File "/usr/local/lib/python3.9/site-packages/jishaku/features/baseclass.py", line 84, in Feature
May 15 17:06:02 [REDACTED] python3.9[31368]: class Command(typing.Generic[GenericFeature, P, T]):  # pylint: disable=too-few-public-methods
May 15 17:06:02 [REDACTED] python3.9[31368]: File "/usr/local/lib/python3.9/typing.py", line 275, in inner
May 15 17:06:02 [REDACTED] python3.9[31368]: return func(*args, **kwds)
May 15 17:06:02 [REDACTED] python3.9[31368]: File "/usr/local/lib/python3.9/typing.py", line 987, in __class_getitem__
May 15 17:06:02 [REDACTED] python3.9[31368]: raise TypeError(
May 15 17:06:02 [REDACTED] python3.9[31368]: TypeError: Parameters to Generic[...] must all be type variables
May 15 17:06:02 [REDACTED] python3.9[31368]: The above exception was the direct cause of the following exception:
May 15 17:06:02 [REDACTED] python3.9[31368]: Traceback (most recent call last):
May 15 17:06:02 [REDACTED] python3.9[31368]: File "/home/[REDACTED]/bot/main.py", line 110, in setup_hook
May 15 17:06:02 [REDACTED] python3.9[31368]: await self.load_extension(module)
May 15 17:06:02 [REDACTED] python3.9[31368]: File "/usr/local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 994, in load_extension
May 15 17:06:02 [REDACTED] python3.9[31368]: await self._load_from_module_spec(spec, name)
May 15 17:06:02 [REDACTED] python3.9[31368]: File "/usr/local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 919, in _load_from_module_spec
May 15 17:06:02 [REDACTED] python3.9[31368]: raise errors.ExtensionFailed(key, e) from e
May 15 17:06:02 [REDACTED] python3.9[31368]: discord.ext.commands.errors.ExtensionFailed: Extension 'jishaku' raised an error: TypeError: Parameters to Generic[...] must all be type variables

Checklist

  • I have updated discord.py and jishaku to the latest available versions and have confirmed that this issue is still present
  • I have searched the open issues for duplicates
  • I have shown the entire traceback, if possible
  • I have removed my token from display, if visible

System information

This was attempted on the latest version of Jishaku. In my development environment, I run 3.8.5, but in production, I run a source-built version of Python 3.9.6. The OS on each is different: development is a Windows 10 Pro machine, while production is CentOS 7.9.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
CubeBlazercommented, Jul 21, 2022

An unideal solution, but removing P from typing.Generic[GenericFeature, P, T] in jishaku.features.baseclass.Feature.Command fixes this issue. This can be traced back to the typing_extensions module:

Note: Can’t fake ParamSpec as a TypeVar to get it to work with Generics. ParamSpec isn’t an instance of TypeVar in 3.10. So encouraging code like isinstance(ParamSpec(‘P’), TypeVar)) will lead to breakage in 3.10. This also means no accurate parameters for GenericAliases. (AN: line 2380-2384)

Really sucks but this solution shouldn’t have any issues

Versions affected by this issue: Pre-3.10

0reactions
pythonmcpicommented, Nov 21, 2022

where updating would require installing basically every library over again, which isn’t fun to do Well, you could pipe the output of pip3.9 freeze into a file, then call pip3.10 install -r filename.txt to reinstall the libraries. You’d have to check if the libraries support 3.10, though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

jishaku as a cog
The jishaku cog contains commands for bot management, debugging and experimentation. The conventional way to add the cog is by using the module...
Read more >
jishaku 2.5.0 on PyPI - Libraries.io
A discord.py extension including useful tools for bot development and debugging. - 2.5.0 - a Python package on PyPI - Libraries.io.
Read more >
Issues · Gorialis/jishaku · GitHub
A debugging and testing cog for discord.py rewrite bots. - Issues · Gorialis/jishaku. ... Can't start bot when using Jishaku 2.5.0.
Read more >
Discord.py Bot Tutorial - Jishaku (Episode #29) | MenuDocs
Require help with y... ... doesn't begin shortly, try restarting your device. Your browser can't play this video. Learn more. Switch camera.
Read more >
jishaku 0.0.5 - PyPI
jishaku is a debugging and experimenting cog for Discord bots using discord.py@rewrite. ... This cog does not work without discord.py@rewrite.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found