Skip to content

Commit 3538dff

Browse files
committed
simplify cache strings
1 parent 01aabef commit 3538dff

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/lib.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,22 @@ pub use validators::{validate_core_schema, PySome, SchemaValidator};
4242

4343
use crate::input::Input;
4444

45-
#[derive(FromPyObject)]
46-
pub enum CacheStringsArg {
47-
Bool(bool),
48-
Literal(StringCacheMode),
49-
}
50-
51-
#[pyfunction(signature = (data, *, allow_inf_nan=true, cache_strings=CacheStringsArg::Bool(true), allow_partial=PartialMode::Off))]
45+
#[pyfunction(signature = (data, *, allow_inf_nan=true, cache_strings=StringCacheMode::All, allow_partial=PartialMode::Off))]
5246
pub fn from_json<'py>(
5347
py: Python<'py>,
5448
data: &Bound<'_, PyAny>,
5549
allow_inf_nan: bool,
56-
cache_strings: CacheStringsArg,
50+
cache_strings: StringCacheMode,
5751
allow_partial: PartialMode,
5852
) -> PyResult<Bound<'py, PyAny>> {
5953
let v_match = data
6054
.validate_bytes(false, ValBytesMode { ser: BytesMode::Utf8 })
6155
.map_err(|_| PyTypeError::new_err("Expected bytes, bytearray or str"))?;
6256
let json_either_bytes = v_match.into_inner();
6357
let json_bytes = json_either_bytes.as_slice();
64-
let cache_mode = match cache_strings {
65-
CacheStringsArg::Bool(b) => b.into(),
66-
CacheStringsArg::Literal(mode) => mode,
67-
};
6858
let parse_builder = PythonParse {
6959
allow_inf_nan,
70-
cache_mode,
60+
cache_mode: cache_strings,
7161
partial_mode: allow_partial,
7262
catch_duplicate_keys: false,
7363
lossless_floats: false,

0 commit comments

Comments
 (0)