Allow to clear explicit image name (#3333)

The documentation says that passing null to `image` allows to clear
the option. Currently `null` is not allowed leading to:
Error: expected string or buffer for dictionary value @ data['image']. Got None

While at it, also update type annotation to reflect what the API
currently allows.
This commit is contained in:
Stefan Agner 2021-11-30 17:48:09 +00:00 committed by GitHub
parent dc24f332f8
commit 79cd8ac390
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -43,7 +43,7 @@ _LOGGER: logging.Logger = logging.getLogger(__name__)
SCHEMA_OPTIONS = vol.Schema( SCHEMA_OPTIONS = vol.Schema(
{ {
vol.Optional(ATTR_BOOT): vol.Boolean(), vol.Optional(ATTR_BOOT): vol.Boolean(),
vol.Optional(ATTR_IMAGE): docker_image, vol.Optional(ATTR_IMAGE): vol.Maybe(docker_image),
vol.Optional(ATTR_PORT): network_port, vol.Optional(ATTR_PORT): network_port,
vol.Optional(ATTR_SSL): vol.Boolean(), vol.Optional(ATTR_SSL): vol.Boolean(),
vol.Optional(ATTR_WATCHDOG): vol.Boolean(), vol.Optional(ATTR_WATCHDOG): vol.Boolean(),

View File

@ -156,7 +156,7 @@ class HomeAssistant(FileConfiguration, CoreSysAttributes):
return f"ghcr.io/home-assistant/{self.sys_machine}-homeassistant" return f"ghcr.io/home-assistant/{self.sys_machine}-homeassistant"
@image.setter @image.setter
def image(self, value: str) -> None: def image(self, value: Optional[str]) -> None:
"""Set image name of Home Assistant container.""" """Set image name of Home Assistant container."""
self._data[ATTR_IMAGE] = value self._data[ATTR_IMAGE] = value
@ -201,7 +201,7 @@ class HomeAssistant(FileConfiguration, CoreSysAttributes):
return self._data.get(ATTR_REFRESH_TOKEN) return self._data.get(ATTR_REFRESH_TOKEN)
@refresh_token.setter @refresh_token.setter
def refresh_token(self, value: str): def refresh_token(self, value: Optional[str]):
"""Set Home Assistant refresh_token.""" """Set Home Assistant refresh_token."""
self._data[ATTR_REFRESH_TOKEN] = value self._data[ATTR_REFRESH_TOKEN] = value