Enable strict typing for rest_command (#107911)

This commit is contained in:
Marc Mueller 2024-01-13 08:48:42 +01:00 committed by GitHub
parent ca1aaacc90
commit 7c98c1e544
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 2 deletions

View file

@ -339,6 +339,7 @@ homeassistant.components.remote.*
homeassistant.components.renault.*
homeassistant.components.repairs.*
homeassistant.components.rest.*
homeassistant.components.rest_command.*
homeassistant.components.rfxtrx.*
homeassistant.components.rhasspy.*
homeassistant.components.ridwell.*

View file

@ -1,8 +1,11 @@
"""Support for exposing regular REST commands as services."""
from __future__ import annotations
import asyncio
from http import HTTPStatus
from json.decoder import JSONDecodeError
import logging
from typing import Any
import aiohttp
from aiohttp import hdrs
@ -86,9 +89,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async_register_rest_command(name, command_config)
@callback
def async_register_rest_command(name, command_config):
def async_register_rest_command(name: str, command_config: dict[str, Any]) -> None:
"""Create service for rest command."""
websession = async_get_clientsession(hass, command_config.get(CONF_VERIFY_SSL))
websession = async_get_clientsession(hass, command_config[CONF_VERIFY_SSL])
timeout = command_config[CONF_TIMEOUT]
method = command_config[CONF_METHOD]

View file

@ -3151,6 +3151,16 @@ disallow_untyped_defs = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.rest_command.*]
check_untyped_defs = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.rfxtrx.*]
check_untyped_defs = true
disallow_incomplete_defs = true