From ba4031718d8ec3d983b7f4fc322e184d76d1ec8e Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Fri, 20 May 2022 06:25:29 +0200 Subject: [PATCH] Enforce application_credentials type hints (#72214) --- pylint/plugins/hass_enforce_type_hints.py | 24 ++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index cb90499b6ca..6cf521addac 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -40,12 +40,16 @@ _MODULE_FILTERS: dict[str, re.Pattern] = { "any_platform": re.compile( f"^homeassistant\\.components\\.\\w+\\.({'|'.join([platform.value for platform in Platform])})$" ), + # application_credentials matches only in the package root (application_credentials.py) + "application_credentials": re.compile( + r"^homeassistant\.components\.\w+\.(application_credentials)$" + ), # device_tracker matches only in the package root (device_tracker.py) "device_tracker": re.compile(r"^homeassistant\.components\.\w+\.(device_tracker)$"), # diagnostics matches only in the package root (diagnostics.py) "diagnostics": re.compile(r"^homeassistant\.components\.\w+\.(diagnostics)$"), # config_flow matches only in the package root (config_flow.py) - "config_flow": re.compile(r"^homeassistant\.components\.\w+\.(config_flow)$") + "config_flow": re.compile(r"^homeassistant\.components\.\w+\.(config_flow)$"), } _METHOD_MATCH: list[TypeHintMatch] = [ @@ -135,6 +139,24 @@ _METHOD_MATCH: list[TypeHintMatch] = [ }, return_type=None, ), + TypeHintMatch( + module_filter=_MODULE_FILTERS["application_credentials"], + function_name="async_get_auth_implementation", + arg_types={ + 0: "HomeAssistant", + 1: "str", + 2: "ClientCredential", + }, + return_type="AbstractOAuth2Implementation", + ), + TypeHintMatch( + module_filter=_MODULE_FILTERS["application_credentials"], + function_name="async_get_authorization_server", + arg_types={ + 0: "HomeAssistant", + }, + return_type="AuthorizationServer", + ), TypeHintMatch( module_filter=_MODULE_FILTERS["device_tracker"], function_name="setup_scanner",