discord.py
discord.py copied to clipboard
Try Disallowing Shadowing at Compile Time in Cogs
I'm thinking of disallowing shadowing with a more descriptive error at compile time for the cog. One thing I worry about is "legitimate" use cases. I could not think of any. I'm tracking this issue to receive comments on whether this should a compile time error the library does to save some support time.
Example of what would be disallowed:
class C(commands.Cog):
@commands.command()
async def foo(self, ctx):
pass
@commands.command()
async def foo(self, ctx):
pass
Considering that the name
keyword argument for the @commands.command()
decorator exists, i don't think that there are many valid uses
Sounds like a no brainer that would probably save headaches on both sides.
I would be curious if anyone could come up with a valid use-case for this. Definitely should raise at compile-time
As long as this only prevents shadowing commands (and not functions) this won't be a large issue.
With the prevention of shadowing all functions in a class built into this, you could break uses of typing.overload
needlessly.
What happens if you subclass a cog and use ctx.invoke(super().command, ...)
or super().command.callback(ctx, ...)
to extend one of the commands?
Nothing?
OK. And if this is a breaking change, why is it being considered?
It's not
Le lun. 24 juin 2019 à 07:45, Ben Mintz [email protected] a écrit :
OK. And if this is a breaking change, why is it being considered?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Rapptz/discord.py/issues/2134?email_source=notifications&email_token=AAXL4HGBLUKQNXBR3EBS7N3P4BNPXA5CNFSM4HKS3CTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYL2LSY#issuecomment-504866251, or mute the thread https://github.com/notifications/unsubscribe-auth/AAXL4HC32WLN6KDKMTNSWFDP4BNPXANCNFSM4HKS3CTA .
It's labeled as such. And this breaks the behavior of a cog which shadows a command name.
@bmintz an issue brought up every once and a while is having a function name foo spread between 2 different command groups. Having an error would make it more obvious to the developer.
It's more of a bug fix than a breaking change. Shadowed commands have never worked.