Loosen constraints on ujson file functions (#10081)

Like `json.dump`, `ujson.dump` takes any object that has a
string-accepting `.write` method.

Similarly, `ujson.load` works with any object with a `.read()` that
returns either a string or a bytes
This commit is contained in:
Tim Stumbaugh
2023-04-24 21:45:50 -06:00
committed by GitHub
parent 1d9f35369d
commit 9abf620500

View File

@@ -1,6 +1,6 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, SupportsRead, SupportsWrite
from collections.abc import Callable
from typing import IO, Any, AnyStr
from typing import Any, AnyStr
__version__: str
@@ -32,7 +32,7 @@ def dumps(
) -> str: ...
def dump(
obj: Any,
fp: IO[str],
fp: SupportsWrite[str],
*,
ensure_ascii: bool = ...,
double_precision: int = ...,
@@ -47,6 +47,6 @@ def dump(
) -> None: ...
def decode(s: AnyStr, precise_float: bool = ...) -> Any: ...
def loads(s: AnyStr, precise_float: bool = ...) -> Any: ...
def load(fp: IO[AnyStr], precise_float: bool = ...) -> Any: ...
def load(fp: SupportsRead[str | bytes], precise_float: bool = ...) -> Any: ...
class JSONDecodeError(ValueError): ...