mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 21:46:42 +08:00
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:
@@ -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): ...
|
||||
|
||||
Reference in New Issue
Block a user