Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
### Packaging
- Update to PyO3 0.24

## Removed
- Remove deprecated `depythonize_bound()`

## 0.23.0 - 2024-11-22

### Packaging
Expand Down
16 changes: 2 additions & 14 deletions src/de.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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<T>(obj: Bound<PyAny>) -> Result<T>
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>,
Expand Down Expand Up @@ -541,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);
});
}

Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
6 changes: 3 additions & 3 deletions src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub trait PythonizeListType: Sized {
fn create_sequence<'py, T, U>(
py: Python<'py>,
elements: impl IntoIterator<Item = T, IntoIter = U>,
) -> PyResult<Bound<PySequence>>
) -> PyResult<Bound<'py, PySequence>>
where
T: IntoPyObject<'py>,
U: ExactSizeIterator<Item = T>;
Expand Down Expand Up @@ -130,7 +130,7 @@ impl PythonizeListType for PyList {
fn create_sequence<'py, T, U>(
py: Python<'py>,
elements: impl IntoIterator<Item = T, IntoIter = U>,
) -> PyResult<Bound<PySequence>>
) -> PyResult<Bound<'py, PySequence>>
where
T: IntoPyObject<'py>,
U: ExactSizeIterator<Item = T>,
Expand All @@ -143,7 +143,7 @@ impl PythonizeListType for PyTuple {
fn create_sequence<'py, T, U>(
py: Python<'py>,
elements: impl IntoIterator<Item = T, IntoIter = U>,
) -> PyResult<Bound<PySequence>>
) -> PyResult<Bound<'py, PySequence>>
where
T: IntoPyObject<'py>,
U: ExactSizeIterator<Item = T>,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_custom_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl PythonizeListType for CustomList {
fn create_sequence<'py, T, U>(
py: Python<'py>,
elements: impl IntoIterator<Item = T, IntoIter = U>,
) -> PyResult<Bound<PySequence>>
) -> PyResult<Bound<'py, PySequence>>
where
T: IntoPyObject<'py>,
U: ExactSizeIterator<Item = T>,
Expand Down