Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't start bot when using Jishaku 2.5.0 #177

Open
4 tasks done
SuperSajuuk opened this issue May 17, 2022 · 7 comments
Open
4 tasks done

Can't start bot when using Jishaku 2.5.0 #177

SuperSajuuk opened this issue May 17, 2022 · 7 comments

Comments

@SuperSajuuk
Copy link

SuperSajuuk commented May 17, 2022

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.

@SuperSajuuk SuperSajuuk changed the title Can't start bot when using Jishaku 2.50 Can't start bot when using Jishaku 2.5.0 May 17, 2022
@scarletcafe
Copy link
Owner

I'm really struggling to replicate this. Can you tell me a bit more about what packages you have (e.g. what lib version you're running), and the Python build information (it appears on the top like when you run the REPL)?

@SuperSajuuk
Copy link
Author

SuperSajuuk commented May 18, 2022

Hi there @Gorialis here's some extra details that might help. I've separated into dev and prod so you can see the different environments (do you want full package lists from pip freeze or is the below suffice?):

NB: In both cases below, I've been attempting to install Jishaku either by doing pip install -U git+https://github.com/Gorialis/jishaku or pip install -U jishaku. I note that in my Windows environment, the installed Jishaku version is at commit 0a1a45d and appears to operate as intended [ie no errors get thrown by Jishaku when loading, despite what seemed to be happening before], despite seemingly erroring at the same commit build as that which was used by Production before it was rolled back. The production code base is identical to that of my development code, so its not like I've introduced anything into Production that wasn't already in development.

Development
The version of Python installed is Python 3.8.5 for 64-bit Window, installed using a Windows Installer package downloaded from the Python website. The build information for this version is included: Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32

In terms of the discord.py package, the version installed is 2.0.0a4269+gb7e25645 which matches the production environment at the moment.

Production
The version of Python installed here is a source-built version, and I can include the build info for that below (which I have extracted by using !jsk on the bot): Python 3.9.6 (default, Jul 17 2021, 14:05:48) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux

The version of discord.py installed on the Production version is discord.py @ git+https://github.com/Rapptz/discord.py@b7e25645dc68bbb828bf1ede711d098c6b183237. I intentionally upgraded my development environment to a newer version of discord.py before upgrading Production, to verify there were no bugs I would encounter by doing so. However, even in Production when using a slightly older version of the library (about 1.5 weeks old in terms of commit history?), the same issue occurred as on Windows. As on the Windows build, Jishaku was attempted to be upgraded by passing the github url or just the package name.

Let me know if you need any other information. :)

@writeblankspace
Copy link

Exception has occurred: ExtensionFailed
Extension 'jishaku' raised an error: TypeError: Parameters to Generic[...] must all be type variables

The above exception was the direct cause of the following exception:

  File "G:\My Drive\.Drive\.VSCODE\.bots\pif paf\bot.py", line 95, in main
    await bot.load_extension(extension)
  File "G:\My Drive\.Drive\.VSCODE\.bots\pif paf\bot.py", line 100, in <module>
    asyncio.run(main())

Got the same issue here. (extension's value is jishaku). I'm also using the dev version of jishaku and using dpy 2.0.

@jaidencreep
Copy link

jaidencreep commented 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

@writeblankspace
Copy link

Updating Python to latest fixed it. I updated from Python 3.9 to 3.10 and the bug was gone.

@SuperSajuuk
Copy link
Author

Updating Python to latest fixed it. I updated from Python 3.9 to 3.10 and the bug was gone.

Good to know, although updating Python just to fix this error doesn't seem a very good idea, considering that discord.py supports Python 3.8 and 3.9 (both of which are my development and production versions respectively, where updating would require installing basically every library over again, which isn't fun to do).

@pythonmcpi
Copy link
Contributor

pythonmcpi commented 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants