Replaced hasattr in dumps with supports_argument

This commit is contained in:
2024-05-26 21:39:55 +02:00
parent 15f9274050
commit 64ba9efa34
4 changed files with 50 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ try:
except ImportError:
from json import dumps, loads
from ._utils import supports_argument
from .sync._nested import nested_delete, nested_set
@@ -36,7 +37,7 @@ async def json_write(data: Any, path: Union[str, Path]) -> None:
async with aiofiles.open(str(path), mode="w", encoding="utf-8") as f:
await f.write(
dumps(data, ensure_ascii=False, escape_forward_slashes=False, indent=4)
if hasattr(dumps, "escape_forward_slashes")
if supports_argument(dumps, "escape_forward_slashes")
else dumps(data, ensure_ascii=False, indent=4)
)