From c9ead2f8d798239976e0134b933c6ae4e8740434 Mon Sep 17 00:00:00 2001 From: Takumasa Nakamura Date: Mon, 5 Feb 2024 11:08:10 +0900 Subject: [PATCH] make add_comments private --- jsonc/__init__.py | 15 ++++++++++++--- jsonc/_add_comments.py | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/jsonc/__init__.py b/jsonc/__init__.py index 1041a51..df2a35b 100644 --- a/jsonc/__init__.py +++ b/jsonc/__init__.py @@ -15,10 +15,10 @@ import json import warnings -from json import JSONDecoder, JSONEncoder # for compatibility +from json import JSONDecodeError, JSONDecoder, JSONEncoder from typing import TYPE_CHECKING -from jsonc._add_comments import add_comments +from jsonc._add_comments import _add_comments from jsonc._util import _add_trailing_comma, _remove_c_comment, _remove_trailing_comma if TYPE_CHECKING: @@ -28,6 +28,15 @@ from jsonc._add_comments import Comments __version__ = "0.0.0" +__all__ = [ + "dump", + "dumps", + "load", + "loads", + "JSONDecoder", + "JSONDecodeError", + "JSONEncoder", +] def load( @@ -130,7 +139,7 @@ def dumps( warnings.warn("Can't add comments to non-indented JSON", stacklevel=2) return data - return add_comments(data, comments) + return _add_comments(data, comments) def dump( diff --git a/jsonc/_add_comments.py b/jsonc/_add_comments.py index 2c094d9..e4d881b 100644 --- a/jsonc/_add_comments.py +++ b/jsonc/_add_comments.py @@ -59,7 +59,7 @@ def _warn_unused( ) -def add_comments(data: str, comments: Comments) -> str: # noqa: C901 +def _add_comments(data: str, comments: Comments) -> str: # noqa: C901 header, cdict = _get_comments({0: copy.deepcopy(comments)}, 0) header = _make_comment(header) + "\n" if header else "" result = []