From b94f6fad668ee9f9db469e684a517923898cada6 Mon Sep 17 00:00:00 2001 From: Maico Timmerman <904824+MaicoTimmerman@users.noreply.github.com> Date: Thu, 8 Oct 2026 08:44:41 +0200 Subject: [PATCH] hvac: add types for hvac.api.secrets_engines.consul Types generated from the provided docstring on the class. The adapter on VaultApiBase already carries its response type, but VaultApiBase currently erases it with Adapter[Any]. We introduce a local generic without affecting the wider hvac API. - RawAdapter methods return Response. - JSONAdapter methods return Response | dict[Any, Any]. - Unparameterized Consul defaults to the standard JSON adapter union. Co-Authored-By: Factory Droid (GPT-5.6 Sol) --- .../hvac/hvac/api/secrets_engines/consul.pyi | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/stubs/hvac/hvac/api/secrets_engines/consul.pyi b/stubs/hvac/hvac/api/secrets_engines/consul.pyi index 0a27a6da6b70..b4688074571f 100644 --- a/stubs/hvac/hvac/api/secrets_engines/consul.pyi +++ b/stubs/hvac/hvac/api/secrets_engines/consul.pyi @@ -1,13 +1,31 @@ +from typing import Any, Final, Generic, TypeVar + +from hvac.adapters import Adapter from hvac.api.vault_api_base import VaultApiBase +from requests import Response + +DEFAULT_MOUNT_POINT: Final = "consul" -DEFAULT_MOUNT_POINT: str +_R = TypeVar("_R", default=Response | dict[Any, Any]) -class Consul(VaultApiBase): - def configure_access(self, address, token, scheme=None, mount_point="consul"): ... +# TODO: Make `hvac.api.vault_api_base.VaultApiBase` generic, and eventually propagate all the way from: +# - `hvac.api.secrets_engines.SecretsEngines` +# - `hvac.v1.Client` +class Consul(VaultApiBase, Generic[_R]): + def __init__(self, adapter: Adapter[_R]) -> None: ... + def configure_access(self, address: str, token: str, scheme: str | None = None, mount_point: str = "consul") -> _R: ... def create_or_update_role( - self, name, policy=None, policies=None, token_type=None, local=None, ttl=None, max_ttl=None, mount_point="consul" - ): ... - def read_role(self, name, mount_point="consul"): ... - def list_roles(self, mount_point="consul"): ... - def delete_role(self, name, mount_point="consul"): ... - def generate_credentials(self, name, mount_point="consul"): ... + self, + name: str, + policy: str | None = None, + policies: list[str] | None = None, + token_type: str | None = None, + local: bool | None = None, + ttl: str | None = None, + max_ttl: str | None = None, + mount_point: str = "consul", + ) -> _R: ... + def read_role(self, name: str, mount_point: str = "consul") -> _R: ... + def list_roles(self, mount_point: str = "consul") -> _R: ... + def delete_role(self, name: str, mount_point: str = "consul") -> _R: ... + def generate_credentials(self, name: str, mount_point: str = "consul") -> _R: ...