From 6fdb68c885d43dc6b3bb30e3c726e9297ee076ae Mon Sep 17 00:00:00 2001 From: David Salvisberg Date: Thu, 22 Aug 2024 08:04:51 +0200 Subject: [PATCH] Adds missing type hint for module functions on `Api` --- src/suitable/api.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/suitable/api.py b/src/suitable/api.py index 3c5e703..bb575e2 100644 --- a/src/suitable/api.py +++ b/src/suitable/api.py @@ -15,7 +15,8 @@ if TYPE_CHECKING: from _typeshed import StrPath - from collections.abc import Generator, Iterable + from collections.abc import Callable, Generator, Iterable + from suitable.runner_results import RunnerResults from suitable.types import Incomplete, ResultData, Verbosity @@ -28,7 +29,7 @@ } -class Api(object): +class Api: """ Provides all available ansible modules as local functions:: @@ -279,6 +280,13 @@ def valid_return_codes(self, *codes: int) -> Generator[None, None, None]: self._valid_return_codes = previous_codes + if TYPE_CHECKING: + # TODO: We could try to auto-generate stubs for the most common + # ansible module functions based on their docs, for now + # we just have a generic fallback to signify that there + # are many methods created through ModuleRunner.hookup + def __getattr__(self, key: str) -> Callable[..., RunnerResults]: ... + def install_strategy_plugins(directories: Iterable[StrPath] | str) -> None: """ Loads the given strategy plugins, which is a list of directories,