Enforce application_credentials type hints (#72214)

This commit is contained in:
epenet 2022-05-20 06:25:29 +02:00 committed by GitHub
parent c028db00de
commit ba4031718d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,12 +40,16 @@ _MODULE_FILTERS: dict[str, re.Pattern] = {
"any_platform": re.compile( "any_platform": re.compile(
f"^homeassistant\\.components\\.\\w+\\.({'|'.join([platform.value for platform in Platform])})$" 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 matches only in the package root (device_tracker.py)
"device_tracker": re.compile(r"^homeassistant\.components\.\w+\.(device_tracker)$"), "device_tracker": re.compile(r"^homeassistant\.components\.\w+\.(device_tracker)$"),
# diagnostics matches only in the package root (diagnostics.py) # diagnostics matches only in the package root (diagnostics.py)
"diagnostics": re.compile(r"^homeassistant\.components\.\w+\.(diagnostics)$"), "diagnostics": re.compile(r"^homeassistant\.components\.\w+\.(diagnostics)$"),
# config_flow matches only in the package root (config_flow.py) # 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] = [ _METHOD_MATCH: list[TypeHintMatch] = [
@ -135,6 +139,24 @@ _METHOD_MATCH: list[TypeHintMatch] = [
}, },
return_type=None, 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( TypeHintMatch(
module_filter=_MODULE_FILTERS["device_tracker"], module_filter=_MODULE_FILTERS["device_tracker"],
function_name="setup_scanner", function_name="setup_scanner",