Skip to content

Commit 5d992b8

Browse files
committed
update to PyO3 0.22
1 parent a65f327 commit 5d992b8

23 files changed

+85
-180
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ include = [
2727
rust-version = "1.75"
2828

2929
[dependencies]
30-
pyo3 = { version = "0.21.2", features = ["generate-import-lib", "num-bigint"] }
30+
# TODO it would be very nice to remove the "py-clone" feature as it can panic,
31+
# but needs a bit of work to make sure it's not used in the codebase
32+
pyo3 = { version = "0.22.0", features = ["generate-import-lib", "num-bigint", "py-clone"] }
3133
regex = "1.10.4"
3234
strum = { version = "0.25.0", features = ["derive"] }
3335
strum_macros = "0.26.1"
@@ -71,12 +73,12 @@ debug = true
7173
strip = false
7274

7375
[dev-dependencies]
74-
pyo3 = { version = "0.21.2", features = ["auto-initialize"] }
76+
pyo3 = { version = "0.22.0", features = ["auto-initialize"] }
7577

7678
[build-dependencies]
7779
version_check = "0.9.4"
7880
# used where logic has to be version/distribution specific, e.g. pypy
79-
pyo3-build-config = { version = "0.21.0" }
81+
pyo3-build-config = { version = "0.22.0" }
8082

8183
[lints.clippy]
8284
dbg_macro = "warn"
@@ -108,3 +110,8 @@ too_many_lines = "allow"
108110
unnecessary_wraps = "allow"
109111
unused_self = "allow"
110112
used_underscore_binding = "allow"
113+
114+
[patch.crates-io]
115+
pyo3 = { git = "https://github.com/pyo3/pyo3", branch = "release-0.22" }
116+
pyo3-build-config = { git = "https://github.com/pyo3/pyo3", branch = "release-0.22" }
117+
jiter = { git = "https://github.com/pydantic/jiter", branch = "dh/pyo3-0.22" }

src/argument_markers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ impl ArgsKwargs {
3030
#[pymethods]
3131
impl ArgsKwargs {
3232
#[new]
33+
#[pyo3(signature = (args, kwargs = None))]
3334
fn py_new(py: Python, args: &Bound<'_, PyTuple>, kwargs: Option<&Bound<'_, PyDict>>) -> Self {
3435
Self {
3536
args: args.into_py(py),

src/errors/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,8 @@ static ERROR_TYPE_LOOKUP: GILOnceCell<AHashMap<String, ErrorType>> = GILOnceCell
459459
impl ErrorType {
460460
pub fn new_custom_error(py: Python, custom_error: PydanticCustomError) -> Self {
461461
Self::CustomError {
462-
error_type: custom_error.error_type(),
463-
message_template: custom_error.message_template(),
462+
error_type: custom_error.error_type().to_owned(),
463+
message_template: custom_error.message_template().to_owned(),
464464
context: custom_error.context(py),
465465
}
466466
}

src/errors/value_exception.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ pub struct PydanticCustomError {
6565
#[pymethods]
6666
impl PydanticCustomError {
6767
#[new]
68+
#[pyo3(signature = (error_type, message_template, context = None))]
6869
pub fn py_new(error_type: String, message_template: String, context: Option<Bound<'_, PyDict>>) -> Self {
6970
Self {
7071
error_type,
@@ -74,13 +75,13 @@ impl PydanticCustomError {
7475
}
7576

7677
#[getter(r#type)]
77-
pub fn error_type(&self) -> String {
78-
self.error_type.clone()
78+
pub fn error_type(&self) -> &str {
79+
&self.error_type
7980
}
8081

8182
#[getter]
82-
pub fn message_template(&self) -> String {
83-
self.message_template.clone()
83+
pub fn message_template(&self) -> &str {
84+
&self.message_template
8485
}
8586

8687
#[getter]
@@ -143,6 +144,7 @@ pub struct PydanticKnownError {
143144
#[pymethods]
144145
impl PydanticKnownError {
145146
#[new]
147+
#[pyo3(signature = (error_type, context=None))]
146148
pub fn py_new(py: Python, error_type: &str, context: Option<Bound<'_, PyDict>>) -> PyResult<Self> {
147149
let error_type = ErrorType::new(py, error_type, context)?;
148150
Ok(Self { error_type })

0 commit comments

Comments
 (0)