diff --git a/CHANGELOG.md b/CHANGELOG.md index 5abc0b6..37fde44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ To see unreleased changes, please see the CHANGELOG on the main branch. Trait `Runtime` now requires `spawn_blocking` function, `future_into_py` functions now require future return type to be `Send`. [#60](https://github.com/PyO3/pyo3-async-runtimes/pull/60) +- Change pyo3 `downcast` calls to `cast` calls [#65](https://github.com/PyO3/pyo3-async-runtimes/pull/65) ## [0.26.0] - 2025-09-02 diff --git a/README.md b/README.md index d686e2e..6080325 100644 --- a/README.md +++ b/README.md @@ -515,7 +515,7 @@ fn main() -> PyResult<()> { assert!(uvloop .bind(py) .getattr("Loop")? - .downcast::() + .cast::() .unwrap() .is_instance(&pyo3_async_runtimes::async_std::get_current_loop(py)?)?); Ok(()) diff --git a/pytests/test_async_std_asyncio.rs b/pytests/test_async_std_asyncio.rs index 96ebd3b..8319c29 100644 --- a/pytests/test_async_std_asyncio.rs +++ b/pytests/test_async_std_asyncio.rs @@ -158,7 +158,7 @@ async fn test_cancel() -> PyResult<()> { assert!(e.value(py).is_instance( py.import("asyncio")? .getattr("CancelledError")? - .downcast::() + .cast::() .unwrap() )?); Ok(()) @@ -240,7 +240,7 @@ fn test_local_cancel(event_loop: Py) -> PyResult<()> { assert!(e.value(py).is_instance( py.import("asyncio")? .getattr("CancelledError")? - .downcast::() + .cast::() .unwrap() )?); Ok(()) diff --git a/pytests/test_async_std_uvloop.rs b/pytests/test_async_std_uvloop.rs index 3afbaff..f1bdbab 100644 --- a/pytests/test_async_std_uvloop.rs +++ b/pytests/test_async_std_uvloop.rs @@ -26,15 +26,8 @@ fn main() -> pyo3::PyResult<()> { pyo3_async_runtimes::async_std::run(py, async move { // verify that we are on a uvloop.Loop Python::attach(|py| -> PyResult<()> { - assert!( - pyo3_async_runtimes::async_std::get_current_loop(py)?.is_instance( - uvloop - .bind(py) - .getattr("Loop")? - .downcast::() - .unwrap() - )? - ); + assert!(pyo3_async_runtimes::async_std::get_current_loop(py)? + .is_instance(uvloop.bind(py).getattr("Loop")?.cast::().unwrap())?); Ok(()) })?; diff --git a/pytests/test_tokio_current_thread_uvloop.rs b/pytests/test_tokio_current_thread_uvloop.rs index 2eef232..d9e2e09 100644 --- a/pytests/test_tokio_current_thread_uvloop.rs +++ b/pytests/test_tokio_current_thread_uvloop.rs @@ -35,15 +35,8 @@ fn main() -> pyo3::PyResult<()> { pyo3_async_runtimes::tokio::run(py, async move { // verify that we are on a uvloop.Loop Python::attach(|py| -> PyResult<()> { - assert!( - pyo3_async_runtimes::tokio::get_current_loop(py)?.is_instance( - uvloop - .bind(py) - .getattr("Loop")? - .downcast::() - .unwrap() - )? - ); + assert!(pyo3_async_runtimes::tokio::get_current_loop(py)? + .is_instance(uvloop.bind(py).getattr("Loop")?.cast::().unwrap())?); Ok(()) })?; diff --git a/pytests/test_tokio_multi_thread_uvloop.rs b/pytests/test_tokio_multi_thread_uvloop.rs index fc37685..6121502 100644 --- a/pytests/test_tokio_multi_thread_uvloop.rs +++ b/pytests/test_tokio_multi_thread_uvloop.rs @@ -27,15 +27,8 @@ fn main() -> pyo3::PyResult<()> { pyo3_async_runtimes::tokio::run(py, async move { // verify that we are on a uvloop.Loop Python::attach(|py| -> PyResult<()> { - assert!( - pyo3_async_runtimes::tokio::get_current_loop(py)?.is_instance( - uvloop - .bind(py) - .getattr("Loop")? - .downcast::() - .unwrap() - )? - ); + assert!(pyo3_async_runtimes::tokio::get_current_loop(py)? + .is_instance(uvloop.bind(py).getattr("Loop")?.cast::().unwrap())?); Ok(()) })?; diff --git a/pytests/tokio_asyncio/mod.rs b/pytests/tokio_asyncio/mod.rs index 40196d5..1a3b9c8 100644 --- a/pytests/tokio_asyncio/mod.rs +++ b/pytests/tokio_asyncio/mod.rs @@ -164,7 +164,7 @@ async fn test_cancel() -> PyResult<()> { assert!(e.value(py).is_instance( py.import("asyncio")? .getattr("CancelledError")? - .downcast::() + .cast::() .unwrap() )?); Ok(()) @@ -216,7 +216,7 @@ fn test_local_cancel(event_loop: Py) -> PyResult<()> { assert!(e.value(py).is_instance( py.import("asyncio")? .getattr("CancelledError")? - .downcast::() + .cast::() .unwrap() )?); Ok(())