diff options
author | 2020-03-28 15:29:49 +0100 | |
---|---|---|
committer | 2020-03-28 15:29:59 +0100 | |
commit | 209439ccd616b1b3ce4ce8d065796850d1395ae5 (patch) | |
tree | 0cbf874aeec61a314a639316ad22d1bee62b97ae | |
parent | Deseasonify: rename utility function (diff) |
Deseasonify: make `get_package_names` an iterator
This simplifies the function and is more in-line with how the function
is being used.
-rw-r--r-- | bot/exts/__init__.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/bot/exts/__init__.py b/bot/exts/__init__.py index 03a686df..4f19c167 100644 --- a/bot/exts/__init__.py +++ b/bot/exts/__init__.py @@ -1,22 +1,18 @@ import logging import pkgutil from pathlib import Path -from typing import List +from typing import Iterator, List __all__ = ("get_package_names", "get_extensions") log = logging.getLogger(__name__) -def get_package_names() -> List[str]: - """Return names of all packages located in /bot/exts/.""" - seasons = [ - package.name - for package in pkgutil.iter_modules(__path__) - if package.ispkg - ] - - return seasons +def get_package_names() -> Iterator[str]: + """Iterate names of all packages located in /bot/exts/.""" + for package in pkgutil.iter_modules(__path__): + if package.ispkg: + yield package.name def get_extensions() -> List[str]: |