From 22ecc9cd88a52b7f6024b18de5d9763f6e3388d3 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Thu, 20 Mar 2025 20:32:07 +0000 Subject: [PATCH 1/2] remove `depythonize_bound` --- CHANGELOG.md | 3 +++ src/de.rs | 9 --------- src/lib.rs | 2 -- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58ab193..8371995 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ### Packaging - Update to PyO3 0.24 +## Removed +- Remove deprecated `depythonize_bound()` + ## 0.23.0 - 2024-11-22 ### Packaging diff --git a/src/de.rs b/src/de.rs index 04e9740..615a2c8 100644 --- a/src/de.rs +++ b/src/de.rs @@ -12,15 +12,6 @@ where T::deserialize(&mut Depythonizer::from_object(obj)) } -/// Attempt to convert a Python object to an instance of `T` -#[deprecated(since = "0.22.0", note = "use `depythonize` instead")] -pub fn depythonize_bound(obj: Bound) -> Result -where - T: DeserializeOwned, -{ - T::deserialize(&mut Depythonizer::from_object(&obj)) -} - /// A structure that deserializes Python objects into Rust values pub struct Depythonizer<'a, 'py> { input: &'a Bound<'py, PyAny>, diff --git a/src/lib.rs b/src/lib.rs index 186fdf6..e625b6f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,8 +4,6 @@ mod de; mod error; mod ser; -#[allow(deprecated)] -pub use crate::de::depythonize_bound; pub use crate::de::{depythonize, Depythonizer}; pub use crate::error::{PythonizeError, Result}; pub use crate::ser::{ From 9b7f985a463adca2bf3ea5c1bbac670ea118dd2c Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Thu, 20 Mar 2025 20:40:25 +0000 Subject: [PATCH 2/2] cleanup --- src/de.rs | 7 ++----- src/ser.rs | 6 +++--- tests/test_custom_types.rs | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/de.rs b/src/de.rs index 615a2c8..49c0889 100644 --- a/src/de.rs +++ b/src/de.rs @@ -1,5 +1,5 @@ use pyo3::{types::*, Bound}; -use serde::de::{self, DeserializeOwned, IntoDeserializer}; +use serde::de::{self, IntoDeserializer}; use serde::Deserialize; use crate::error::{ErrorImpl, PythonizeError, Result}; @@ -532,12 +532,9 @@ mod test { let obj = py.eval(code, None, None).unwrap(); let actual: T = depythonize(&obj).unwrap(); assert_eq!(&actual, expected); + let actual_json: JsonValue = depythonize(&obj).unwrap(); assert_eq!(&actual_json, expected_json); - - #[allow(deprecated)] - let actual: T = depythonize_bound(obj.clone()).unwrap(); - assert_eq!(&actual, expected); }); } diff --git a/src/ser.rs b/src/ser.rs index efc7e29..513a8e2 100644 --- a/src/ser.rs +++ b/src/ser.rs @@ -55,7 +55,7 @@ pub trait PythonizeListType: Sized { fn create_sequence<'py, T, U>( py: Python<'py>, elements: impl IntoIterator, - ) -> PyResult> + ) -> PyResult> where T: IntoPyObject<'py>, U: ExactSizeIterator; @@ -130,7 +130,7 @@ impl PythonizeListType for PyList { fn create_sequence<'py, T, U>( py: Python<'py>, elements: impl IntoIterator, - ) -> PyResult> + ) -> PyResult> where T: IntoPyObject<'py>, U: ExactSizeIterator, @@ -143,7 +143,7 @@ impl PythonizeListType for PyTuple { fn create_sequence<'py, T, U>( py: Python<'py>, elements: impl IntoIterator, - ) -> PyResult> + ) -> PyResult> where T: IntoPyObject<'py>, U: ExactSizeIterator, diff --git a/tests/test_custom_types.rs b/tests/test_custom_types.rs index 1f5dfd4..d311c14 100644 --- a/tests/test_custom_types.rs +++ b/tests/test_custom_types.rs @@ -36,7 +36,7 @@ impl PythonizeListType for CustomList { fn create_sequence<'py, T, U>( py: Python<'py>, elements: impl IntoIterator, - ) -> PyResult> + ) -> PyResult> where T: IntoPyObject<'py>, U: ExactSizeIterator,