aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md5
-rw-r--r--botcore/utils/__init__.py21
-rw-r--r--botcore/utils/_monkey_patches.py (renamed from botcore/utils/monkey_patches.py)15
-rw-r--r--docs/utils.py5
-rw-r--r--pyproject.toml2
5 files changed, 30 insertions, 18 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 67aca72b..09287fc4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,10 +1,13 @@
# Changelog
+## 3.0.0 3rd March 2021
+ - Breaking: Move `apply_monkey_patches()` directly to `botcore.utils` namespace
+
## 2.1.0 24th February 2022
- Feature: Port the Site API wrapper from the bot repo.
## 2.0.0 22nd February 2022
-- Breaking: Moved regex to botcore.utils namespace
+- Breaking: Moved regex to `botcore.utils` namespace
- Feature: Migrate from discord.py 2.0a0 to disnake.
- Feature: Add common monkey patches.
- Feature: Port many common utilities from our bots
diff --git a/botcore/utils/__init__.py b/botcore/utils/__init__.py
index 890f30da..07ded04d 100644
--- a/botcore/utils/__init__.py
+++ b/botcore/utils/__init__.py
@@ -1,14 +1,31 @@
"""Useful utilities and tools for Discord bot development."""
-from botcore.utils import (caching, channel, extensions, logging, members, monkey_patches, regex, scheduling)
+from botcore.utils import _monkey_patches, caching, channel, extensions, logging, members, regex, scheduling
+
+
+def apply_monkey_patches() -> None:
+ """
+ Applies all common monkey patches for our bots.
+
+ Patches :obj:`disnake.ext.commands.Command` and :obj:`disnake.ext.commands.Group` to support root aliases.
+ A ``root_aliases`` keyword argument is added to these two objects, which is a sequence of alias names
+ that will act as top-level groups rather than being aliases of the command's group.
+
+ It's stored as an attribute also named ``root_aliases``
+
+ Patches disnake's internal ``send_typing`` method so that it ignores 403 errors from Discord.
+ When under heavy load Discord has added a CloudFlare worker to this route, which causes 403 errors to be thrown.
+ """
+ _monkey_patches._apply_monkey_patches()
+
__all__ = [
+ apply_monkey_patches,
caching,
channel,
extensions,
logging,
members,
- monkey_patches,
regex,
scheduling,
]
diff --git a/botcore/utils/monkey_patches.py b/botcore/utils/_monkey_patches.py
index abbb37a5..89238756 100644
--- a/botcore/utils/monkey_patches.py
+++ b/botcore/utils/_monkey_patches.py
@@ -62,19 +62,8 @@ def _patch_typing() -> None:
http.HTTPClient.send_typing = honeybadger_type
-def apply_monkey_patches() -> None:
- """
- Applies all common monkey patches for our bots.
-
- Patches :obj:`disnake.ext.commands.Command` and :obj:`disnake.ext.commands.Group` to support root aliases.
- A ``root_aliases`` keyword argument is added to these two objects, which is a sequence of alias names
- that will act as top-level groups rather than being aliases of the command's group.
-
- It's stored as an attribute also named ``root_aliases``
-
- Patches disnake's internal ``send_typing`` method so that it ignores 403 errors from Discord.
- When under heavy load Discord has added a CloudFlare worker to this route, which causes 403 errors to be thrown.
- """
+def _apply_monkey_patches() -> None:
+ """This is surfaced directly in botcore.utils.apply_monkey_patches()."""
commands.command = partial(commands.command, cls=_Command)
commands.GroupMixin.command = partialmethod(commands.GroupMixin.command, cls=_Command)
diff --git a/docs/utils.py b/docs/utils.py
index 76b3e098..9116c130 100644
--- a/docs/utils.py
+++ b/docs/utils.py
@@ -105,7 +105,10 @@ def __get_included() -> set[str]:
"""Get a list of files that should be included in the final build."""
def get_all_from_module(module_name: str) -> set[str]:
- module = importlib.import_module(module_name)
+ try:
+ module = importlib.import_module(module_name)
+ except ModuleNotFoundError:
+ return {}
_modules = {module.__name__ + ".rst"}
if hasattr(module, "__all__"):
diff --git a/pyproject.toml b/pyproject.toml
index c003cfc0..188edb8f 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "bot-core"
-version = "2.1.0"
+version = "3.0.0"
description = "Bot-Core provides the core functionality and utilities for the bots of the Python Discord community."
authors = ["Python Discord <[email protected]>"]
license = "MIT"