aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/CODEOWNERS2
-rw-r--r--bot/converters.py10
-rw-r--r--bot/exts/utils/extensions.py7
-rw-r--r--bot/utils/extensions.py34
-rw-r--r--poetry.lock6
-rw-r--r--pyproject.toml2
6 files changed, 12 insertions, 49 deletions
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index ea69f7677..0bc2bb793 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -18,10 +18,8 @@ bot/exts/recruitment/** @wookie184
bot/rules/** @mbaruh
# Utils
-bot/utils/extensions.py @MarkKoz
bot/utils/function.py @MarkKoz
bot/utils/lock.py @MarkKoz
-bot/utils/scheduling.py @MarkKoz
# Tests
tests/_autospec.py @MarkKoz
diff --git a/bot/converters.py b/bot/converters.py
index a3f4630a0..7393a1ddc 100644
--- a/bot/converters.py
+++ b/bot/converters.py
@@ -9,19 +9,19 @@ import dateutil.parser
import discord
from aiohttp import ClientConnectorError
from botcore.site_api import ResponseCodeError
+from botcore.utils import unqualify
from botcore.utils.regex import DISCORD_INVITE
from dateutil.relativedelta import relativedelta
from discord.ext.commands import BadArgument, Bot, Context, Converter, IDConverter, MemberConverter, UserConverter
from discord.utils import escape_markdown, snowflake_time
-from bot import exts
+from bot import exts, instance as bot_instance
from bot.constants import URLs
from bot.errors import InvalidInfraction
from bot.exts.info.doc import _inventory_parser
from bot.exts.info.tags import TagIdentifier
from bot.log import get_logger
from bot.utils import time
-from bot.utils.extensions import EXTENSIONS, unqualify
if t.TYPE_CHECKING:
from bot.exts.info.source import SourceType
@@ -150,13 +150,13 @@ class Extension(Converter):
argument = argument.lower()
- if argument in EXTENSIONS:
+ if argument in bot_instance.all_extensions:
return argument
- elif (qualified_arg := f"{exts.__name__}.{argument}") in EXTENSIONS:
+ elif (qualified_arg := f"{exts.__name__}.{argument}") in bot_instance.all_extensions:
return qualified_arg
matches = []
- for ext in EXTENSIONS:
+ for ext in bot_instance.all_extensions:
if argument == unqualify(ext):
matches.append(ext)
diff --git a/bot/exts/utils/extensions.py b/bot/exts/utils/extensions.py
index 95ce94c2c..9862988cb 100644
--- a/bot/exts/utils/extensions.py
+++ b/bot/exts/utils/extensions.py
@@ -12,7 +12,6 @@ from bot.constants import Emojis, MODERATION_ROLES, Roles, URLs
from bot.converters import Extension
from bot.log import get_logger
from bot.pagination import LinePaginator
-from bot.utils.extensions import EXTENSIONS
log = get_logger(__name__)
@@ -53,7 +52,7 @@ class Extensions(commands.Cog):
return
if "*" in extensions or "**" in extensions:
- extensions = set(EXTENSIONS) - set(self.bot.extensions.keys())
+ extensions = set(self.bot.all_extensions) - set(self.bot.extensions.keys())
msg = self.batch_manage(Action.LOAD, *extensions)
await ctx.send(msg)
@@ -96,7 +95,7 @@ class Extensions(commands.Cog):
return
if "**" in extensions:
- extensions = EXTENSIONS
+ extensions = self.bot.all_extensions
elif "*" in extensions:
extensions = set(self.bot.extensions.keys()) | set(extensions)
extensions.remove("*")
@@ -136,7 +135,7 @@ class Extensions(commands.Cog):
"""Return a mapping of extension names and statuses to their categories."""
categories = {}
- for ext in EXTENSIONS:
+ for ext in self.bot.all_extensions:
if ext in self.bot.extensions:
status = Emojis.status_online
else:
diff --git a/bot/utils/extensions.py b/bot/utils/extensions.py
deleted file mode 100644
index 50350ea8d..000000000
--- a/bot/utils/extensions.py
+++ /dev/null
@@ -1,34 +0,0 @@
-import importlib
-import inspect
-import pkgutil
-from typing import Iterator, NoReturn
-
-from bot import exts
-
-
-def unqualify(name: str) -> str:
- """Return an unqualified name given a qualified module/package `name`."""
- return name.rsplit(".", maxsplit=1)[-1]
-
-
-def walk_extensions() -> Iterator[str]:
- """Yield extension names from the bot.exts subpackage."""
-
- def on_error(name: str) -> NoReturn:
- raise ImportError(name=name) # pragma: no cover
-
- for module in pkgutil.walk_packages(exts.__path__, f"{exts.__name__}.", onerror=on_error):
- if unqualify(module.name).startswith("_"):
- # Ignore module/package names starting with an underscore.
- continue
-
- if module.ispkg:
- imported = importlib.import_module(module.name)
- if not inspect.isfunction(getattr(imported, "setup", None)):
- # If it lacks a setup function, it's not an extension.
- continue
-
- yield module.name
-
-
-EXTENSIONS = frozenset(walk_extensions())
diff --git a/poetry.lock b/poetry.lock
index e90274559..c16ccfb45 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -125,7 +125,7 @@ lxml = ["lxml"]
[[package]]
name = "bot-core"
-version = "6.0.0"
+version = "6.1.0"
description = "Bot-Core provides the core functionality and utilities for the bots of the Python Discord community."
category = "main"
optional = false
@@ -141,7 +141,7 @@ async-rediscache = ["async-rediscache[fakeredis] (==0.2.0)"]
[package.source]
type = "url"
-url = "https://github.com/python-discord/bot-core/archive/refs/tags/v6.0.0.zip"
+url = "https://github.com/python-discord/bot-core/archive/refs/tags/v6.1.0.zip"
[[package]]
name = "certifi"
version = "2021.10.8"
@@ -1150,7 +1150,7 @@ multidict = ">=4.0"
[metadata]
lock-version = "1.1"
python-versions = "3.9.*"
-content-hash = "3a9451cdbafd9880f794fe5ea4ece75663a778708707e7b5fb5e9aaffc2bbbc8"
+content-hash = "69566bc6bf522bdad4db9bf4409f2a69d1027e04cef1134d8aeac7ef9ce004f1"
[metadata.files]
aiodns = [
diff --git a/pyproject.toml b/pyproject.toml
index 2a4415419..466b16e2c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -10,7 +10,7 @@ python = "3.9.*"
"discord.py" = {url = "https://github.com/Rapptz/discord.py/archive/987235d5649e7c2b1a927637bab6547244ecb2cf.zip"}
# See https://bot-core.pythondiscord.com/ for docs.
-bot-core = {url = "https://github.com/python-discord/bot-core/archive/refs/tags/v6.0.0.zip", extras = ["async-rediscache"]}
+bot-core = {url = "https://github.com/python-discord/bot-core/archive/refs/tags/v6.1.0.zip", extras = ["async-rediscache"]}
aiodns = "3.0.0"
aiohttp = "3.8.1"