Comments (7)
Since the Feature rewrite redoing how subclasses work, I don't think it would really be possible to reproduce this issue anymore on the latest version. If such a scenario arises, then a new issue can be made about it, but I haven't had anyone run into this problem since so I'm assuming it probably no longer applies.
from jishaku.
Given that there aren't any diagnostics in this issue and v1 hasn't changed since the v2 push, I can't really assume anything other than your install has become broken somehow.
The immediate thing I'd expect to fix it is just doing:
pip uninstall jishaku
pip install -U --no-deps --force-reinstall jishaku
If that fails, you will have to run through some diagnostic steps yourself:
- Are the modules themselves importable? (e.g. does
from jishaku.repl.compilation import AsyncCodeExecutor
work?) If yes, then it's probably a bad reload and you should try reloading again or restarting your interpreter, otherwise - If you look into the
jishaku
directory insite-packages
, can you see the submodules? (you can find out where it's installed if you don't know by doingjsk pyi jishaku
) If you can, then likewise again, it's probably a bad reload and you should try reloading again or restarting your interpreter. If not, then, well, that's likely the problem.
Other potential culprits are maybe permissions issues, but regardless, this doesn't seem like anything caused by jishaku.
from jishaku.
I have done all the above. the from x import y
does seem to be working, and everything in the commands seem to be working as well (when I load default jishaku, not my subclass). like the from jishaku.repl.compilation import AsyncCodeExecutor
works, but when I try to jishaku.repl.compilation.CORO_CODE = NEW_CORO_CODE
, I get the AttributeError: module 'jishaku' has no attribute 'repl'
error... I have reinstalled and reloaded many times already now, but nothing seems to be working.
For some reason it wont let me add a screenshot, but in the link below you can see that somehow the from jishaku import repl
does work but checking with an hasattr returns False
https://media.discordapp.net/attachments/460568954968997890/787844477766991903/unknown.png
from jishaku.
Do you have import jishaku
in your custom extension file (the one you do bot.add_cog(...)
in)?
I think the likely explanation for why this happens probably stems from how discord.py resolves extension submodule dependencies.
I'm guessing that because you do something along the lines of from jishaku.cog import ...
, discord.py detects that jishaku.cog
and its recursive submodule references need to be reloaded, and reloads them, but doesn't reload jishaku
itself. Thus, the jishaku
module object is left with dead references that get removed, even though the modules do themselves exist post-reload, so you get the confusing scenario where from jishaku import cog
works but import jishaku.cog; jishaku.cog
does not.
As an interesting aside, before the new reload logic was even added into discord.py, jishaku was mostly responsible for its own reload, and even had a dedicated command for it back in the day. A remnant of this logic is actually still present even in the current v2 code, labelled only vaguely as "panic recovery mode".
If my speculation is right, I'm not really sure what the solution to it would be. If the library was itself adjusted to reload parent modules, you'd get odd situations where stuff would get reloaded when it really shouldn't be (cogs.games
reloading cogs
, etc). On the other hand, I can't make jishaku.cog
or such depend on jishaku
because it would result in a circular import.
If you don't already have import jishaku
in your extension file, and adding it fixes it, I suppose that's the best solution for now, even if it results in a seemingly redundant import.
Another potential slapstick fix would be to force a reload of the main module at load time:
import importlib
import jishaku
...
def setup(bot: commands.Bot):
importlib.reload(jishaku)
bot.add_cog(CustomJishaku(bot=bot))
I don't like either of these as permanent solutions, so I'll probably have to dig into how the submodule resolution works again and see if I can fool discord.py into reloading jishaku subclass extensions properly.
from jishaku.
So I have been trying out multiple things, and what eventually seemed to be the breaking change was
import jishaku
jishaku.repl.compilation.CORO_CODE = NEW_CORO_CODE
This would not work anymore. Which is weird because it always worked even on 1.20 until someday it magically stopped working
from jishaku import repl
repl.compilation.CORO_CODE = NEW_CORO_CODE
This is the solution that fixed the issue for me.
Personally I dont see how there is any difference, but I'm also not the biggest expert at this as I often just think like "if it works, dont touch it" :)
from jishaku.
I do have another question about subclassing commands in v2.0.0.. I know its not officially released yet but since I like to keep my things updated I wanted to look into this before the final release. Would you want me to open a separate issue for this? Or is there any place on discord where I can ask for this?
from jishaku.
I'm still scratching my head over this problem... I can't seem to replicate it no matter what I do. I reckon it's definitely something to do with extension management, and maybe whatever behavior caused this is fixed in discord.py, or maybe there's a behavior difference between Python versions.
I'm thinking about writing some unit tests for things like this, as well as just some ones for testing subclass behavior in general, since honestly those need to be done before 2.0 has a realistic chance of releasing... maybe it'll reveal something, who knows.
from jishaku.
Related Issues (20)
- ability to add user who can run jishaku on the fly HOT 2
- Button disable
- Add Whois command HOT 2
- Unsupport discord.py v1.7.x HOT 1
- Python 3.9.13 not supported HOT 1
- Proper user configurable jsk py dict vars HOT 1
- change jishaku commands names HOT 1
- Jishaku version occasionally appears as vNone in selftest HOT 4
- Adding asqlite to options for the sql features HOT 3
- Unhandled code branch in `jishaku voice` command.
- Cog already loaded when loading it HOT 1
- I canβt use jishaku shell command HOT 2
- `jishaku timeit` raises an AttributeError upon use. HOT 1
- Tracking: need for a new release
- KeyError on Python version 3.11.0 HOT 3
- AttributeError: 'Context' object has no attribute 'add_reaction' HOT 2
- Question about next possible release to pypi HOT 2
- Convert message links to Message objects in REPLs HOT 1
- [Tracking] import_expression doesn't function correctly in 3.12 HOT 3
- jsk sync command broken on dpy master HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jishaku.