Giter VIP home page Giter VIP logo

Comments (7)

Gorialis avatar Gorialis commented on June 19, 2024 1

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.

Gorialis avatar Gorialis commented on June 19, 2024

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 in site-packages, can you see the submodules? (you can find out where it's installed if you don't know by doing jsk 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.

iDutchy avatar iDutchy commented on June 19, 2024

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.

Gorialis avatar Gorialis commented on June 19, 2024

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.

iDutchy avatar iDutchy commented on June 19, 2024

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.

iDutchy avatar iDutchy commented on June 19, 2024

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.

Gorialis avatar Gorialis commented on June 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.