aboutsummaryrefslogtreecommitdiffstats
path: root/botcore/utils
diff options
context:
space:
mode:
Diffstat (limited to 'botcore/utils')
-rw-r--r--botcore/utils/__init__.py3
-rw-r--r--botcore/utils/_extensions.py (renamed from botcore/utils/extensions.py)9
2 files changed, 4 insertions, 8 deletions
diff --git a/botcore/utils/__init__.py b/botcore/utils/__init__.py
index fe906075..7e6ea788 100644
--- a/botcore/utils/__init__.py
+++ b/botcore/utils/__init__.py
@@ -1,6 +1,6 @@
"""Useful utilities and tools for Discord bot development."""
-from botcore.utils import _monkey_patches, caching, channel, extensions, logging, members, regex, scheduling
+from botcore.utils import _monkey_patches, caching, channel, logging, members, regex, scheduling
def apply_monkey_patches() -> None:
@@ -23,7 +23,6 @@ __all__ = [
apply_monkey_patches,
caching,
channel,
- extensions,
logging,
members,
regex,
diff --git a/botcore/utils/extensions.py b/botcore/utils/_extensions.py
index 841120c9..6848fae6 100644
--- a/botcore/utils/extensions.py
+++ b/botcore/utils/_extensions.py
@@ -28,14 +28,13 @@ def walk_extensions(module: types.ModuleType) -> frozenset[str]:
module (types.ModuleType): The module to look for extensions in.
Returns:
- A set of strings that can be passed directly to :obj:`discord.ext.commands.Bot.load_extension`.
+ An iterator object, that returns a string that can be passed directly to
+ :obj:`discord.ext.commands.Bot.load_extension` on call to next().
"""
def on_error(name: str) -> NoReturn:
raise ImportError(name=name) # pragma: no cover
- modules = set()
-
for module_info in pkgutil.walk_packages(module.__path__, f"{module.__name__}.", onerror=on_error):
if unqualify(module_info.name).startswith("_"):
# Ignore module/package names starting with an underscore.
@@ -47,6 +46,4 @@ def walk_extensions(module: types.ModuleType) -> frozenset[str]:
# If it lacks a setup function, it's not an extension.
continue
- modules.add(module_info.name)
-
- return frozenset(modules)
+ yield module_info.name