Skip to content

Commit 214b8c8

Browse files
committed
resolve deprecations
1 parent 2659521 commit 214b8c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+234
-236
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ rust-version = "1.75"
2727
[dependencies]
2828
# TODO it would be very nice to remove the "py-clone" feature as it can panic,
2929
# but needs a bit of work to make sure it's not used in the codebase
30-
pyo3 = { version = "0.26", features = ["generate-import-lib", "num-bigint", "py-clone"] }
30+
pyo3 = { version = "0.27", features = ["generate-import-lib", "num-bigint", "py-clone"] }
3131
regex = "1.11.1"
3232
strum = { version = "0.27", features = ["derive"] }
3333
strum_macros = "0.27"
@@ -68,12 +68,12 @@ debug = true
6868
strip = false
6969

7070
[dev-dependencies]
71-
pyo3 = { version = "0.26", features = ["auto-initialize"] }
71+
pyo3 = { version = "0.27", features = ["auto-initialize"] }
7272

7373
[build-dependencies]
7474
version_check = "0.9.5"
7575
# used where logic has to be version/distribution specific, e.g. pypy
76-
pyo3-build-config = { version = "0.26" }
76+
pyo3-build-config = { version = "0.27" }
7777

7878
[lints.clippy]
7979
dbg_macro = "warn"
@@ -107,6 +107,6 @@ unused_self = "allow"
107107
used_underscore_binding = "allow"
108108

109109
[patch.crates-io]
110-
pyo3 = { git = "https://github.com/pyo3/pyo3.git" }
111-
pyo3-build-config = { git = "https://github.com/pyo3/pyo3.git" }
110+
pyo3 = { git = "https://github.com/pyo3/pyo3.git", branch = "release-0.27.0" }
111+
pyo3-build-config = { git = "https://github.com/pyo3/pyo3.git", branch = "release-0.27.0" }
112112
jiter = { git = "https://github.com/pydantic/jiter.git", branch = "dh/pyo3-0.27" }

src/errors/line_error.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::convert::Infallible;
22

33
use pyo3::exceptions::PyTypeError;
44
use pyo3::prelude::*;
5-
use pyo3::DowncastError;
6-
use pyo3::DowncastIntoError;
5+
use pyo3::CastError;
6+
use pyo3::CastIntoError;
77

88
use jiter::JsonValue;
99

@@ -45,15 +45,15 @@ impl From<PyErr> for ValError {
4545
}
4646
}
4747

48-
impl From<DowncastError<'_, '_>> for ValError {
49-
fn from(py_downcast: DowncastError) -> Self {
50-
Self::InternalErr(PyTypeError::new_err(py_downcast.to_string()))
48+
impl From<CastError<'_, '_>> for ValError {
49+
fn from(py_cast: CastError) -> Self {
50+
Self::InternalErr(PyTypeError::new_err(py_cast.to_string()))
5151
}
5252
}
5353

54-
impl From<DowncastIntoError<'_>> for ValError {
55-
fn from(py_downcast: DowncastIntoError) -> Self {
56-
Self::InternalErr(PyTypeError::new_err(py_downcast.to_string()))
54+
impl From<CastIntoError<'_>> for ValError {
55+
fn from(py_cast: CastIntoError) -> Self {
56+
Self::InternalErr(PyTypeError::new_err(py_cast.to_string()))
5757
}
5858
}
5959

src/errors/location.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ impl TryFrom<Option<&Bound<'_, PyAny>>> for Location {
176176
/// Thus this expects the location to *not* be reversed and reverses it before storing it.
177177
fn try_from(location: Option<&Bound<'_, PyAny>>) -> PyResult<Self> {
178178
if let Some(location) = location {
179-
let mut loc_vec: Vec<LocItem> = if let Ok(tuple) = location.downcast::<PyTuple>() {
179+
let mut loc_vec: Vec<LocItem> = if let Ok(tuple) = location.cast::<PyTuple>() {
180180
tuple.iter().map(Into::into).collect()
181-
} else if let Ok(list) = location.downcast::<PyList>() {
181+
} else if let Ok(list) = location.cast::<PyList>() {
182182
list.iter().map(Into::into).collect()
183183
} else {
184184
return Err(PyTypeError::new_err(

src/errors/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ macro_rules! error_types {
127127
dict.set_item(stringify!($key), $key)?;
128128
)*
129129
if let Some(ctx) = context {
130-
dict.update(ctx.bind(py).downcast::<PyMapping>()?)?;
130+
dict.update(ctx.bind(py).cast::<PyMapping>()?)?;
131131
Ok(true)
132132
} else {
133133
Ok(false)

src/errors/validation_exception.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,14 +433,14 @@ impl TryFrom<&Bound<'_, PyAny>> for PyLineError {
433433
type Error = PyErr;
434434

435435
fn try_from(value: &Bound<'_, PyAny>) -> PyResult<Self> {
436-
let dict = value.downcast::<PyDict>()?;
436+
let dict = value.cast::<PyDict>()?;
437437
let py = value.py();
438438

439439
let type_raw = dict
440440
.get_item(intern!(py, "type"))?
441441
.ok_or_else(|| PyKeyError::new_err("type"))?;
442442

443-
let error_type = if let Ok(type_str) = type_raw.downcast::<PyString>() {
443+
let error_type = if let Ok(type_str) = type_raw.cast::<PyString>() {
444444
let context: Option<Bound<'_, PyDict>> = dict.get_as(intern!(py, "ctx"))?;
445445
ErrorType::new(py, type_str.to_str()?, context)?
446446
} else if let Ok(custom_error) = type_raw.extract::<PydanticCustomError>() {

src/errors/value_exception.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ impl PydanticCustomError {
120120
let mut message = message_template.to_string();
121121
if let Some(ctx) = context {
122122
for (key, value) in ctx.iter() {
123-
let key = key.downcast::<PyString>()?;
124-
if let Ok(py_str) = value.downcast::<PyString>() {
123+
let key = key.cast::<PyString>()?;
124+
if let Ok(py_str) = value.cast::<PyString>() {
125125
message = message.replace(&format!("{{{}}}", key.to_str()?), py_str.to_str()?);
126126
} else if let Some(value_int) = extract_i64(&value) {
127127
message = message.replace(&format!("{{{}}}", key.to_str()?), &value_int.to_string());

src/input/datetime.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,10 @@ impl<'py> TryFrom<&'_ Bound<'py, PyAny>> for EitherTimedelta<'py> {
226226
type Error = PyErr;
227227

228228
fn try_from(value: &Bound<'py, PyAny>) -> PyResult<Self> {
229-
if let Ok(dt) = value.downcast_exact() {
229+
if let Ok(dt) = value.cast_exact() {
230230
Ok(EitherTimedelta::PyExact(dt.clone()))
231231
} else {
232-
let dt = value.downcast()?;
232+
let dt = value.cast()?;
233233
Ok(EitherTimedelta::PySubclass(dt.clone()))
234234
}
235235
}
@@ -344,7 +344,7 @@ fn time_as_tzinfo<'py>(py: Python<'py>, time: &Time) -> PyResult<Option<Bound<'p
344344
match time.tz_offset {
345345
Some(offset) => {
346346
let tz_info: TzInfo = offset.try_into()?;
347-
Ok(Some(Bound::new(py, tz_info)?.into_any().downcast_into()?))
347+
Ok(Some(Bound::new(py, tz_info)?.into_any().cast_into()?))
348348
}
349349
None => Ok(None),
350350
}

0 commit comments

Comments
 (0)