diff --git a/.strict-typing b/.strict-typing index 339622c0f11..c81721d926c 100644 --- a/.strict-typing +++ b/.strict-typing @@ -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.* diff --git a/homeassistant/components/browser/__init__.py b/homeassistant/components/browser/__init__.py index fc0e9eccb3a..f8c1278fbd9 100644 --- a/homeassistant/components/browser/__init__.py +++ b/homeassistant/components/browser/__init__.py @@ -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, ) diff --git a/mypy.ini b/mypy.ini index 1ad9fc03c72..1a5fb092299 100644 --- a/mypy.ini +++ b/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