From 9fff3198bd34c47378b54096daa5ec42e973a123 Mon Sep 17 00:00:00 2001 From: Xing Han Lu <21180505+xhluca@users.noreply.github.com> Date: Thu, 7 Mar 2024 19:05:24 -0500 Subject: [PATCH] Fix Indent problem for auto_save_json --- weblinx/utils/__init__.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/weblinx/utils/__init__.py b/weblinx/utils/__init__.py index 3377b87..7628d74 100644 --- a/weblinx/utils/__init__.py +++ b/weblinx/utils/__init__.py @@ -206,13 +206,13 @@ def auto_read_json(path, backend="auto"): return data -def auto_save_json(data, path, backend="auto", indent=None): + +def auto_save_json(data, path, backend="auto", indent=0): + if indent is None: + indent = 0 + path = str(path) - if ( - backend in ["auto", "orjson"] - and find_spec("orjson") - and indent not in [2, None] - ): + if backend in ["auto", "orjson"] and find_spec("orjson") and indent not in [2, 0]: import orjson backend = "orjson" @@ -236,7 +236,7 @@ def auto_save_json(data, path, backend="auto", indent=None): elif backend == "orjson": if indent == 2: option = orjson.OPT_INDENT_2 - elif indent is None: + elif indent == 0: option = None else: raise ValueError(