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.renault.*
homeassistant.components.repairs.* homeassistant.components.repairs.*
homeassistant.components.rest.* homeassistant.components.rest.*
homeassistant.components.rest_command.*
homeassistant.components.rfxtrx.* homeassistant.components.rfxtrx.*
homeassistant.components.rhasspy.* homeassistant.components.rhasspy.*
homeassistant.components.ridwell.* homeassistant.components.ridwell.*

View File

@ -1,8 +1,11 @@
"""Support for exposing regular REST commands as services.""" """Support for exposing regular REST commands as services."""
from __future__ import annotations
import asyncio import asyncio
from http import HTTPStatus from http import HTTPStatus
from json.decoder import JSONDecodeError from json.decoder import JSONDecodeError
import logging import logging
from typing import Any
import aiohttp import aiohttp
from aiohttp import hdrs from aiohttp import hdrs
@ -86,9 +89,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async_register_rest_command(name, command_config) async_register_rest_command(name, command_config)
@callback @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.""" """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] timeout = command_config[CONF_TIMEOUT]
method = command_config[CONF_METHOD] method = command_config[CONF_METHOD]

View File

@ -3151,6 +3151,16 @@ disallow_untyped_defs = true
warn_return_any = true warn_return_any = true
warn_unreachable = 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.*] [mypy-homeassistant.components.rfxtrx.*]
check_untyped_defs = true check_untyped_defs = true
disallow_incomplete_defs = true disallow_incomplete_defs = true