1
mirror of https://github.com/home-assistant/core synced 2024-10-01 05:30:36 +02:00

Fix incorrect reference to json WriteError (#88161)

This commit is contained in:
epenet 2023-02-15 10:40:26 +01:00 committed by GitHub
parent 6c430e03bc
commit a1b7842df2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -15,6 +15,7 @@ from homeassistant.const import EVENT_HOMEASSISTANT_FINAL_WRITE
from homeassistant.core import CALLBACK_TYPE, CoreState, Event, HomeAssistant, callback
from homeassistant.loader import MAX_LOAD_CONCURRENTLY, bind_hass
from homeassistant.util import json as json_util
from homeassistant.util.file import WriteError
# mypy: allow-untyped-calls, allow-untyped-defs, no-warn-return-any
# mypy: no-check-untyped-defs
@ -278,7 +279,7 @@ class Store(Generic[_T]):
try:
await self._async_write_data(self.path, data)
except (json_util.SerializationError, json_util.WriteError) as err:
except (json_util.SerializationError, WriteError) as err:
_LOGGER.error("Error writing config for %s: %s", self.key, err)
async def _async_write_data(self, path: str, data: dict) -> None:

View File

@ -16,7 +16,11 @@ from homeassistant.helpers.json import (
json_encoder_default as default_hass_orjson_encoder,
)
from .file import write_utf8_file, write_utf8_file_atomic
from .file import ( # pylint: disable=unused-import # noqa: F401
WriteError,
write_utf8_file,
write_utf8_file_atomic,
)
_LOGGER = logging.getLogger(__name__)
@ -25,10 +29,6 @@ class SerializationError(HomeAssistantError):
"""Error serializing the data to JSON."""
class WriteError(HomeAssistantError):
"""Error writing the data."""
def load_json(filename: str, default: list | dict | None = None) -> list | dict:
"""Load JSON data from a file and return as dict or list.