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
|
from typing import Any, Union, TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
def dumps(obj: Any) -> bytes: ... # type: ignore
|
def dumps(obj: Any) -> bytes: ... # type: ignore # noqa: E704
|
||||||
def loads(data: Union[str, bytes, bytearray]) -> Any: ...
|
def loads(data: Union[str, bytes, bytearray]) -> Any: ... # noqa: E704
|
||||||
|
|
||||||
MSGSPEC_ENABLED = False
|
MSGSPEC_ENABLED = False
|
||||||
_msgspc_var = os.getenv("MOONRAKER_ENABLE_MSGSPEC", "y").lower()
|
_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
|
from msgspec import DecodeError as JSONDecodeError
|
||||||
encoder = msgspec.json.Encoder()
|
encoder = msgspec.json.Encoder()
|
||||||
decoder = msgspec.json.Decoder()
|
decoder = msgspec.json.Decoder()
|
||||||
dumps = encoder.encode
|
dumps = encoder.encode # noqa: F811
|
||||||
loads = decoder.decode
|
loads = decoder.decode # noqa: F811
|
||||||
MSGSPEC_ENABLED = True
|
MSGSPEC_ENABLED = True
|
||||||
if not MSGSPEC_ENABLED:
|
if not MSGSPEC_ENABLED:
|
||||||
import json
|
import json
|
||||||
from json import JSONDecodeError # type: ignore
|
from json import JSONDecodeError # type: ignore # noqa: F401,F811
|
||||||
loads = json.loads # type: ignore
|
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")
|
return json.dumps(obj).encode("utf-8")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user