Remove cloud from mypy ignore list (#74449)
This commit is contained in:
parent
3e98ac180c
commit
911402e747
4 changed files with 14 additions and 13 deletions
|
@ -419,6 +419,7 @@ async def websocket_hook_delete(hass, connection, msg):
|
|||
async def _account_data(hass: HomeAssistant, cloud: Cloud):
|
||||
"""Generate the auth data JSON response."""
|
||||
|
||||
assert hass.config.api
|
||||
if not cloud.is_logged_in:
|
||||
return {
|
||||
"logged_in": False,
|
||||
|
|
|
@ -6,7 +6,9 @@ from http import HTTPStatus
|
|||
from ipaddress import ip_address
|
||||
import logging
|
||||
import secrets
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from aiohttp import StreamReader
|
||||
from aiohttp.web import Request, Response
|
||||
import voluptuous as vol
|
||||
|
||||
|
@ -17,7 +19,7 @@ from homeassistant.helpers.network import get_url
|
|||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.loader import bind_hass
|
||||
from homeassistant.util import network
|
||||
from homeassistant.util.aiohttp import MockRequest, serialize_response
|
||||
from homeassistant.util.aiohttp import MockRequest, MockStreamReader, serialize_response
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -83,17 +85,20 @@ def async_generate_path(webhook_id: str) -> str:
|
|||
|
||||
@bind_hass
|
||||
async def async_handle_webhook(
|
||||
hass: HomeAssistant, webhook_id: str, request: Request
|
||||
hass: HomeAssistant, webhook_id: str, request: Request | MockRequest
|
||||
) -> Response:
|
||||
"""Handle a webhook."""
|
||||
handlers = hass.data.setdefault(DOMAIN, {})
|
||||
handlers: dict[str, dict[str, Any]] = hass.data.setdefault(DOMAIN, {})
|
||||
|
||||
# Always respond successfully to not give away if a hook exists or not.
|
||||
if (webhook := handlers.get(webhook_id)) is None:
|
||||
content_stream: StreamReader | MockStreamReader
|
||||
if isinstance(request, MockRequest):
|
||||
received_from = request.mock_source
|
||||
content_stream = request.content
|
||||
else:
|
||||
received_from = request.remote
|
||||
content_stream = request.content
|
||||
|
||||
_LOGGER.info(
|
||||
"Received message for unregistered webhook %s from %s",
|
||||
|
@ -102,13 +107,16 @@ async def async_handle_webhook(
|
|||
)
|
||||
# Look at content to provide some context for received webhook
|
||||
# Limit to 64 chars to avoid flooding the log
|
||||
content = await request.content.read(64)
|
||||
content = await content_stream.read(64)
|
||||
_LOGGER.debug("%s", content)
|
||||
return Response(status=HTTPStatus.OK)
|
||||
|
||||
if webhook["local_only"]:
|
||||
if TYPE_CHECKING:
|
||||
assert isinstance(request, Request)
|
||||
assert request.remote is not None
|
||||
try:
|
||||
remote = ip_address(request.remote) # type: ignore[arg-type]
|
||||
remote = ip_address(request.remote)
|
||||
except ValueError:
|
||||
_LOGGER.debug("Unable to parse remote ip %s", request.remote)
|
||||
return Response(status=HTTPStatus.OK)
|
||||
|
|
6
mypy.ini
6
mypy.ini
|
@ -2656,12 +2656,6 @@ no_implicit_optional = false
|
|||
warn_return_any = false
|
||||
warn_unreachable = false
|
||||
|
||||
[mypy-homeassistant.components.cloud.client]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.cloud.http_api]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.sonos]
|
||||
ignore_errors = true
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@ from .model import Config, Integration
|
|||
# remove your component from this list to enable type checks.
|
||||
# Do your best to not add anything new here.
|
||||
IGNORED_MODULES: Final[list[str]] = [
|
||||
"homeassistant.components.cloud.client",
|
||||
"homeassistant.components.cloud.http_api",
|
||||
"homeassistant.components.sonos",
|
||||
"homeassistant.components.sonos.alarms",
|
||||
"homeassistant.components.sonos.binary_sensor",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue