Skip to content

Commit

Permalink
fix signature of from_json
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Mar 21, 2024
1 parent 97d45a3 commit 6c51c06
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions python/pydantic_core/_pydantic_core.pyi
Expand Up @@ -384,7 +384,12 @@ def to_json(
JSON bytes.
"""

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

0 comments on commit 6c51c06

Please sign in to comment.