Skip to content

Commit 6c51c06

Browse files
committed
fix signature of from_json
1 parent 97d45a3 commit 6c51c06

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

python/pydantic_core/_pydantic_core.pyi

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,12 @@ def to_json(
384384
JSON bytes.
385385
"""
386386

387-
def from_json(data: str | bytes | bytearray, *, allow_inf_nan: bool = True, cache_strings: bool = True) -> Any:
387+
def from_json(
388+
data: str | bytes | bytearray,
389+
*,
390+
allow_inf_nan: bool = True,
391+
cache_strings: bool | Literal['all', 'keys', 'none'] = True,
392+
) -> Any:
388393
"""
389394
Deserialize JSON data to a Python object.
390395
@@ -394,7 +399,8 @@ def from_json(data: str | bytes | bytearray, *, allow_inf_nan: bool = True, cach
394399
data: The JSON data to deserialize.
395400
allow_inf_nan: Whether to allow `Infinity`, `-Infinity` and `NaN` values as `json.loads()` does by default.
396401
cache_strings: Whether to cache strings to avoid constructing new Python objects,
397-
this should have a significant impact on performance while increasing memory usage slightly.
402+
this should have a significant impact on performance while increasing memory usage slightly,
403+
`all/True` means cache all strings, `keys` means cache only dict keys, `none/False` means no caching.
398404
399405
Raises:
400406
ValueError: If deserialization fails.

0 commit comments

Comments
 (0)