Skip to content

Commit 37ad925

Browse files
Uprev jiter to v0.4.1 and pydantic-core to v2.18.4 (#1306)
Co-authored-by: David Hewitt <david.hewitt@pydantic.dev>
1 parent 81e3bd3 commit 37ad925

File tree

5 files changed

+74
-10
lines changed

5 files changed

+74
-10
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ jobs:
9090
python-version: ${{ matrix.python-version }}
9191

9292
- run: pip install -r tests/requirements.txt
93+
# TODO: remove this after the the next release of typing-extensions (v4.12.3 or v.4.13.0)
94+
- run: pip uninstall -y typing-extensions
95+
- run: pip install -U git+https://github.com/python/typing_extensions@main
9396

9497
- run: pip install -e .
9598
env:

Cargo.lock

Lines changed: 43 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pydantic-core"
3-
version = "2.18.3"
3+
version = "2.18.4"
44
edition = "2021"
55
license = "MIT"
66
homepage = "https://github.com/pydantic/pydantic-core"
@@ -44,7 +44,7 @@ base64 = "0.21.7"
4444
num-bigint = "0.4.4"
4545
python3-dll-a = "0.2.7"
4646
uuid = "1.8.0"
47-
jiter = { version = "0.2.1", features = ["python"] }
47+
jiter = { version = "0.4.1", features = ["python"] }
4848

4949
[lib]
5050
name = "_pydantic_core"

src/lib.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ extern crate core;
44

55
use std::sync::OnceLock;
66

7-
use jiter::StringCacheMode;
7+
use jiter::{map_json_error, PartialMode, PythonParse, StringCacheMode};
88
use pyo3::exceptions::PyTypeError;
99
use pyo3::{prelude::*, sync::GILOnceCell};
1010

@@ -63,8 +63,21 @@ pub fn from_json<'py>(
6363
CacheStringsArg::Bool(b) => b.into(),
6464
CacheStringsArg::Literal(mode) => mode,
6565
};
66-
jiter::python_parse(py, json_bytes, allow_inf_nan, cache_mode, allow_partial)
67-
.map_err(|e| jiter::map_json_error(json_bytes, &e))
66+
let partial_mode = if allow_partial {
67+
PartialMode::On
68+
} else {
69+
PartialMode::Off
70+
};
71+
let parse_builder = PythonParse {
72+
allow_inf_nan,
73+
cache_mode,
74+
partial_mode,
75+
catch_duplicate_keys: false,
76+
lossless_floats: false,
77+
};
78+
parse_builder
79+
.python_parse(py, json_bytes)
80+
.map_err(|e| map_json_error(json_bytes, &e))
6881
}
6982

7083
pub fn get_pydantic_core_version() -> &'static str {

src/validators/json.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use pyo3::intern;
22
use pyo3::prelude::*;
33
use pyo3::types::PyDict;
44

5-
use jiter::JsonValue;
5+
use jiter::{JsonValue, PartialMode, PythonParse};
66

77
use crate::errors::{ErrorType, ErrorTypeDefaults, ValError, ValLineError, ValResult};
88
use crate::input::{EitherBytes, Input, InputType, ValidationMatch};
@@ -64,7 +64,15 @@ impl Validator for JsonValidator {
6464
validator.validate(py, &json_value, &mut json_state)
6565
}
6666
None => {
67-
let obj = jiter::python_parse(py, json_bytes, true, state.cache_str(), false)
67+
let parse_builder = PythonParse {
68+
allow_inf_nan: true,
69+
cache_mode: state.cache_str(),
70+
partial_mode: PartialMode::Off,
71+
catch_duplicate_keys: false,
72+
lossless_floats: false,
73+
};
74+
let obj = parse_builder
75+
.python_parse(py, json_bytes)
6876
.map_err(|e| map_json_err(input, e, json_bytes))?;
6977
Ok(obj.unbind())
7078
}

0 commit comments

Comments
 (0)