Switch loader to use json helper (#73872)

This commit is contained in:
J. Nick Koston 2022-06-22 21:57:38 -05:00 committed by GitHub
parent b5f6f785d5
commit 164eba7e5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -7,6 +7,7 @@ from typing import Any, Final
import orjson import orjson
JSON_ENCODE_EXCEPTIONS = (TypeError, ValueError) JSON_ENCODE_EXCEPTIONS = (TypeError, ValueError)
JSON_DECODE_EXCEPTIONS = (orjson.JSONDecodeError,)
class JSONEncoder(json.JSONEncoder): class JSONEncoder(json.JSONEncoder):

View File

@ -11,7 +11,6 @@ from collections.abc import Callable
from contextlib import suppress from contextlib import suppress
import functools as ft import functools as ft
import importlib import importlib
import json
import logging import logging
import pathlib import pathlib
import sys import sys
@ -30,6 +29,7 @@ from .generated.mqtt import MQTT
from .generated.ssdp import SSDP from .generated.ssdp import SSDP
from .generated.usb import USB from .generated.usb import USB
from .generated.zeroconf import HOMEKIT, ZEROCONF from .generated.zeroconf import HOMEKIT, ZEROCONF
from .helpers.json import JSON_DECODE_EXCEPTIONS, json_loads
from .util.async_ import gather_with_concurrency from .util.async_ import gather_with_concurrency
# Typing imports that create a circular dependency # Typing imports that create a circular dependency
@ -366,8 +366,8 @@ class Integration:
continue continue
try: try:
manifest = json.loads(manifest_path.read_text()) manifest = json_loads(manifest_path.read_text())
except ValueError as err: except JSON_DECODE_EXCEPTIONS as err:
_LOGGER.error( _LOGGER.error(
"Error parsing manifest.json file at %s: %s", manifest_path, err "Error parsing manifest.json file at %s: %s", manifest_path, err
) )