@@ -42,38 +42,23 @@ pub use validators::{validate_core_schema, PySome, SchemaValidator};
42
42
43
43
use crate :: input:: Input ;
44
44
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=false ) ) ]
45
+ #[ pyfunction( signature = ( data, * , allow_inf_nan=true , cache_strings=StringCacheMode :: All , allow_partial=PartialMode :: Off ) ) ]
52
46
pub fn from_json < ' py > (
53
47
py : Python < ' py > ,
54
48
data : & Bound < ' _ , PyAny > ,
55
49
allow_inf_nan : bool ,
56
- cache_strings : CacheStringsArg ,
57
- allow_partial : bool ,
50
+ cache_strings : StringCacheMode ,
51
+ allow_partial : PartialMode ,
58
52
) -> PyResult < Bound < ' py , PyAny > > {
59
53
let v_match = data
60
54
. validate_bytes ( false , ValBytesMode { ser : BytesMode :: Utf8 } )
61
55
. map_err ( |_| PyTypeError :: new_err ( "Expected bytes, bytearray or str" ) ) ?;
62
56
let json_either_bytes = v_match. into_inner ( ) ;
63
57
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
- } ;
68
- let partial_mode = if allow_partial {
69
- PartialMode :: On
70
- } else {
71
- PartialMode :: Off
72
- } ;
73
58
let parse_builder = PythonParse {
74
59
allow_inf_nan,
75
- cache_mode,
76
- partial_mode,
60
+ cache_mode : cache_strings ,
61
+ partial_mode : allow_partial ,
77
62
catch_duplicate_keys : false ,
78
63
lossless_floats : false ,
79
64
} ;
0 commit comments