Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions stdlib/json/decoder.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import sys
from _typeshed import Incomplete
from collections.abc import Callable
from re import Match
from typing import Any

__all__ = ["JSONDecoder", "JSONDecodeError"]
Expand All @@ -12,6 +14,34 @@ class JSONDecodeError(ValueError):
colno: int
def __init__(self, msg: str, doc: str, pos: int) -> None: ...

def JSONObject(
s_and_end: tuple[str, int],
strict: bool,
scan_once: Callable[[str, int], tuple[Any, int]],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think to fulfill our "Any needs to be documented" required, we should introduce type aliases. Or leave as Incomplete for now. These Anys are not obvious to me at least.

object_hook: Callable[[dict[str, Any]], Any] | None,
object_pairs_hook: Callable[[list[tuple[str, Any]]], Any] | None,
memo: dict[str, str] | None = None,
_w: Callable[[str, int], Match[str] | None] = ...,
_ws: str = ...,
) -> tuple[Any, int]: ...

if sys.version_info >= (3, 15):
def JSONArray(
s_and_end: tuple[str, int],
scan_once: Callable[[str, int], tuple[Any, int]],
array_hook: Callable[[list[Any]], Any] | None,
_w: Callable[[str, int], Match[str] | None] = ...,
_ws: str = ...,
) -> tuple[Any, int]: ...

else:
def JSONArray(
s_and_end: tuple[str, int],
scan_once: Callable[[str, int], tuple[Any, int]],
_w: Callable[[str, int], Match[str] | None] = ...,
_ws: str = ...,
) -> tuple[list[Any], int]: ...

class JSONDecoder:
if sys.version_info >= (3, 15):
array_hook: Callable[[list[Any]], Any] | None
Expand All @@ -21,6 +51,10 @@ class JSONDecoder:
parse_constant: Callable[[str], Any]
strict: bool
object_pairs_hook: Callable[[list[tuple[str, Any]]], Any]
parse_object: Callable[..., Incomplete]
parse_array: Callable[..., Incomplete]
parse_string: Callable[..., Incomplete]
memo: dict[str, str]
if sys.version_info >= (3, 15):
def __init__(
self,
Expand Down