json_wrapper: fix linter errors
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
d721ec5d9c
commit
4fe99e6ebb
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue