json_wrapper: fix linter errors

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2023-10-07 10:37:42 -04:00
parent d721ec5d9c
commit 4fe99e6ebb
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
1 changed files with 6 additions and 6 deletions

View File

@ -10,8 +10,8 @@ import contextlib
from typing import Any, Union, TYPE_CHECKING
if TYPE_CHECKING:
def dumps(obj: Any) -> bytes: ... # type: ignore
def loads(data: Union[str, bytes, bytearray]) -> Any: ...
def dumps(obj: Any) -> bytes: ... # type: ignore # noqa: E704
def loads(data: Union[str, bytes, bytearray]) -> Any: ... # noqa: E704
MSGSPEC_ENABLED = False
_msgspc_var = os.getenv("MOONRAKER_ENABLE_MSGSPEC", "y").lower()
@ -21,13 +21,13 @@ if _msgspc_var in ["y", "yes", "true"]:
from msgspec import DecodeError as JSONDecodeError
encoder = msgspec.json.Encoder()
decoder = msgspec.json.Decoder()
dumps = encoder.encode
loads = decoder.decode
dumps = encoder.encode # noqa: F811
loads = decoder.decode # noqa: F811
MSGSPEC_ENABLED = True
if not MSGSPEC_ENABLED:
import json
from json import JSONDecodeError # type: ignore
from json import JSONDecodeError # type: ignore # noqa: F401,F811
loads = json.loads # type: ignore
def dumps(obj) -> bytes: # type: ignore
def dumps(obj) -> bytes: # type: ignore # noqa: F811
return json.dumps(obj).encode("utf-8")