-
-
Notifications
You must be signed in to change notification settings - Fork 675
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
Incorrect handling of tags by the !source
command
#2022
Comments
I can implement this tonight, if no one else wants to do it before then |
Looks like this is caused by how we're loading extensions, if the source cog is loaded before the tags cog, then the Although when it does work it uses the wrong path so that should be fixed in the source cog at L68 |
Yeah, I moved TagIdentifier to a separate file, and that it solves the problem. |
While that does solve the problem, I feel like it's more of a bandaid solution. |
We shouldn't be importing from extensions since reload and loading will now have undefined behavior. I don't think we import from extensions that much... oh no In order to make loading extension respect already imported modules, we would need to get deep into the implementation of discord.ext.commands.Bot.load_extension, and importlib Here's the core magic of extension loading. Any change we make to this would make reload_extension have even more undefined behavior. We may also need to write code to figure out and track imports and calculate a dependency tree to order the extensions. |
UPDATE: after futher invesigation, most of the above imports are being used for type hinting, and the cogs do use get_cog There's one case where I found one cog being imported from another module, which is below. Simple matter of updating to get_cog
Most of the 47 above imports could be done up like the below: bot/bot/exts/recruitment/talentpool/_review.py Lines 25 to 26 in db85e56
|
I think |
The issue is still there, although only if the cogs are loaded in a certain order. Running |
While the solution presented in the PR above works (by not checking for isinstance of TagIdentifier entirely), I don't think it's very robust in the long run. It looks like This skips checking for (Draft implementation: http://0x0.st/Xs2e.patch - not very polished, just a proof-of-concept!) What do we think of this solution? |
@hedyhli I agree that your proposal sounds more robust. Lets do it. Were you planning to do the PR for it? |
Sure, I'll see to it once I'm free within the next week or two. |
When trying to use the source command on a tag, it errors out and the exception is not caught:
A simple solution would be to just catch the exception, but since it's a very identifiable scenario (being an instance of
TagIdentifier
), we can instead point to the appropriate MD file in the repo.EDIT: This actually seems to have worked before #1663
The text was updated successfully, but these errors were encountered: