From 3de886dc62894bd669965a02dcef2d3e8074ef11 Mon Sep 17 00:00:00 2001 From: BJ Dierkes Date: Sat, 13 Jul 2024 17:56:04 -0500 Subject: [PATCH] Type Annotations: core.plugin - Resolves Issue #707 - Related to PR #628 --- CHANGELOG.md | 1 + cement/core/plugin.py | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f81fdd35..53737218 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ Refactoring: - `[core.mail]` [Issue #704](https://github.com/datafolklabs/cement/issues/704) - `[core.meta]` [Issue #705](https://github.com/datafolklabs/cement/issues/705) - `[core.output]` [Issue #706](https://github.com/datafolklabs/cement/issues/706) + - `[core.plugin]` [Issue #707](https://github.com/datafolklabs/cement/issues/707) - `[utils.fs]` [Issue #688](https://github.com/datafolklabs/cement/issues/688) - `[utils.misc]` [Issue #689](https://github.com/datafolklabs/cement/issues/689) - `[utils.shell]` [Issue #690](https://github.com/datafolklabs/cement/issues/690) diff --git a/cement/core/plugin.py b/cement/core/plugin.py index 50115315..66451d1d 100644 --- a/cement/core/plugin.py +++ b/cement/core/plugin.py @@ -1,6 +1,7 @@ """Cement core plugins module.""" from abc import abstractmethod +from typing import List from ..core.interface import Interface from ..core.handler import Handler from ..utils.misc import minimal_logger @@ -17,13 +18,13 @@ class PluginInterface(Interface): :class:`PluginHandler` base class as a starting point. """ - class Meta: + class Meta(Interface.Meta): #: String identifier of the interface. interface = 'plugin' @abstractmethod - def load_plugin(plugin_name): + def load_plugin(self, plugin_name: str) -> None: """ Load a plugin whose name is ``plugin_name``. @@ -34,7 +35,7 @@ class PluginInterface(Interface): pass # pragma: nocover @abstractmethod - def load_plugins(self, plugins): + def load_plugins(self, plugins: List[str]) -> None: """ Load all plugins from ``plugins``. @@ -45,17 +46,17 @@ class PluginInterface(Interface): pass # pragma: nocover @abstractmethod - def get_loaded_plugins(self): + def get_loaded_plugins(self) -> List[str]: """Returns a list of plugins that have been loaded.""" pass # pragma: nocover @abstractmethod - def get_enabled_plugins(self): + def get_enabled_plugins(self) -> List[str]: """Returns a list of plugins that are enabled in the config.""" pass # pragma: nocover @abstractmethod - def get_disabled_plugins(self): + def get_disabled_plugins(self) -> List[str]: """Returns a list of plugins that are disabled in the config.""" pass # pragma: nocover @@ -67,4 +68,5 @@ class PluginHandler(PluginInterface, Handler): """ - pass # pragma: nocover + class Meta(Handler.Meta): + pass # pragma: nocover