Enable strict typing in browser (#63760)
* Add setup type hints to browser * Add browser to script-typingpull/63773/head
parent
9479ef0a34
commit
36dd8ca09a
|
@ -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.*
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
||||
|
|
11
mypy.ini
11
mypy.ini
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue