mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Enable strict typing in browser (#63760)
* Add setup type hints to browser * Add browser to script-typing
This commit is contained in:
parent
9479ef0a34
commit
36dd8ca09a
@ -25,6 +25,7 @@ homeassistant.components.bmw_connected_drive.*
|
|||||||
homeassistant.components.bond.*
|
homeassistant.components.bond.*
|
||||||
homeassistant.components.braviatv.*
|
homeassistant.components.braviatv.*
|
||||||
homeassistant.components.brother.*
|
homeassistant.components.brother.*
|
||||||
|
homeassistant.components.browser.*
|
||||||
homeassistant.components.button.*
|
homeassistant.components.button.*
|
||||||
homeassistant.components.calendar.*
|
homeassistant.components.calendar.*
|
||||||
homeassistant.components.camera.*
|
homeassistant.components.camera.*
|
||||||
|
@ -3,6 +3,9 @@ import webbrowser
|
|||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
ATTR_URL = "url"
|
ATTR_URL = "url"
|
||||||
ATTR_URL_DEFAULT = "https://www.google.com"
|
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."""
|
"""Listen for browse_url events."""
|
||||||
|
|
||||||
hass.services.register(
|
hass.services.register(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
SERVICE_BROWSE_URL,
|
SERVICE_BROWSE_URL,
|
||||||
lambda service: webbrowser.open(service.data[ATTR_URL]),
|
_browser_url,
|
||||||
schema=SERVICE_BROWSE_URL_SCHEMA,
|
schema=SERVICE_BROWSE_URL_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
11
mypy.ini
11
mypy.ini
@ -286,6 +286,17 @@ no_implicit_optional = true
|
|||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = 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.*]
|
[mypy-homeassistant.components.button.*]
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user