1
0
mirror of https://github.com/home-assistant/core synced 2024-07-03 08:18:59 +00:00

Enable strict typing in browser (#63760)

* Add setup type hints to browser

* Add browser to script-typing
This commit is contained in:
epenet 2022-01-10 04:02:50 +01:00 committed by GitHub
parent 9479ef0a34
commit 36dd8ca09a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View File

@ -25,6 +25,7 @@ homeassistant.components.bmw_connected_drive.*
homeassistant.components.bond.*
homeassistant.components.braviatv.*
homeassistant.components.brother.*
homeassistant.components.browser.*
homeassistant.components.button.*
homeassistant.components.calendar.*
homeassistant.components.camera.*

View File

@ -3,6 +3,9 @@ import webbrowser
import voluptuous as vol
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.helpers.typing import ConfigType
ATTR_URL = "url"
ATTR_URL_DEFAULT = "https://www.google.com"
@ -18,13 +21,18 @@ SERVICE_BROWSE_URL_SCHEMA = vol.Schema(
)
def setup(hass, config):
def _browser_url(service: ServiceCall) -> None:
"""Browse to URL."""
webbrowser.open(service.data[ATTR_URL])
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Listen for browse_url events."""
hass.services.register(
DOMAIN,
SERVICE_BROWSE_URL,
lambda service: webbrowser.open(service.data[ATTR_URL]),
_browser_url,
schema=SERVICE_BROWSE_URL_SCHEMA,
)

View File

@ -286,6 +286,17 @@ no_implicit_optional = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.browser.*]
check_untyped_defs = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
no_implicit_optional = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.button.*]
check_untyped_defs = true
disallow_incomplete_defs = true