I've recently developed a tool that goes in and makes sure that each __init__.py matches up with the __all__s in files/folders in the same directory as it. For example, if there was a statement like from .channel import GuildText, the program will go in and make sure the __all__ of channel is ("GuildText",), and fixes the import if the __all__ doesn't match up. It also detects if the __init__ isn't importing a file with a __all__ in it and adds it to the import.
This tool is far from ready, but I've gotten it to a state where I could run a run on the interactions.py library. Wouldn't you know it, we are missing some imports, so I made this PR to add them back in. This PR also fixes some other issues I was running into involving the codebase, like GuildMedia not being properly exposed in channel.py.
As a (hopefully good) consequence of this program, __all__ for __init__.pys that have been affected have been put in alphabetical order.
Changes
Add GuildMedia to __all__ in channel.py for models.
Export CronTrigger.
Export LocalisedField and LocalizedField.
Export ClientObject and DiscordObject. You may argue against it, but I'd argue that there's no good reason to not export them, and they can have their uses.
Oh right, this program also picked up deserialize_app_cmds, interestingly enough.
Do an alphabetical sort for all __all__s that have been adjusted.
Related Issues
Test Scenarios
Python Compatibility
[x] I've ensured my code works on Python 3.10.x
[ ] I've ensured my code works on Python 3.11.x
Checklist
[x] I've run the pre-commit code linter over all edited files
[x] I've tested my changes on supported Python versions
[ ] I've added tests for my code, if applicable
[ ] I've updated / added documentation, where applicable
Pull Request Type
Description
I've recently developed a tool that goes in and makes sure that each
__init__.py
matches up with the__all__
s in files/folders in the same directory as it. For example, if there was a statement likefrom .channel import GuildText
, the program will go in and make sure the__all__
ofchannel
is("GuildText",)
, and fixes the import if the__all__
doesn't match up. It also detects if the__init__
isn't importing a file with a__all__
in it and adds it to the import.This tool is far from ready, but I've gotten it to a state where I could run a run on the interactions.py library. Wouldn't you know it, we are missing some imports, so I made this PR to add them back in. This PR also fixes some other issues I was running into involving the codebase, like
GuildMedia
not being properly exposed inchannel.py
.As a (hopefully good) consequence of this program,
__all__
for__init__.py
s that have been affected have been put in alphabetical order.Changes
GuildMedia
to__all__
inchannel.py
for models.CronTrigger
.LocalisedField
andLocalizedField
.ClientObject
andDiscordObject
. You may argue against it, but I'd argue that there's no good reason to not export them, and they can have their uses.deserialize_app_cmds
, interestingly enough.__all__
s that have been adjusted.Related Issues
Test Scenarios
Python Compatibility
3.10.x
3.11.x
Checklist
pre-commit
code linter over all edited files