Cog-Creators / Red-DiscordBot

A multi-function Discord bot
https://docs.discord.red
GNU General Public License v3.0
4.72k stars 2.3k forks source link

[Config] Prevent registering defaults for inaccessible identifiers #6290

Open Flame442 opened 7 months ago

Flame442 commented 7 months ago

What component of Red (cog, command, API) would you like to see improvements on?

Config

Describe the enhancement you're suggesting.

When registering defaults, we already check that the key is not a Python identifier, however we do not ever check whether the key is an existing attribute of Group or Value that will cause the __getattr__ method to never be called. Examples include:

And more!

A similar check should be added to ensure the key is actually going to be accessible, in order to prevent confusion.

Anything else?

No response

Kreusada commented 7 months ago

+1 on this, would be an important addition especially with the default identifier as I see that getting used occasionally.