From 7162e0fd6e94b0723989b639ed682a95263bfa30 Mon Sep 17 00:00:00 2001 From: Rik Bouwmeester Date: Mon, 9 Mar 2026 15:05:02 +0100 Subject: [PATCH 1/2] Add wait_disconnect method to Crazyflie class for graceful disconnection --- cflib2/_rust.pyi | 6 ++++++ rust/src/crazyflie.rs | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/cflib2/_rust.pyi b/cflib2/_rust.pyi index 4fff888..78e14eb 100644 --- a/cflib2/_rust.pyi +++ b/cflib2/_rust.pyi @@ -324,6 +324,12 @@ class Crazyflie: r""" Disconnect from the Crazyflie """ + async def wait_disconnect(self) -> str: + r""" + Wait for the Crazyflie to be disconnected + + Returns a human-readable string describing the reason for disconnection. + """ def commander(self) -> Commander: r""" Get the commander subsystem diff --git a/rust/src/crazyflie.rs b/rust/src/crazyflie.rs index f0ad7bc..f30a96d 100644 --- a/rust/src/crazyflie.rs +++ b/rust/src/crazyflie.rs @@ -134,6 +134,18 @@ impl Crazyflie { }) } + /// Wait for the Crazyflie to be disconnected + /// + /// Returns a human-readable string describing the reason for disconnection. + #[gen_stub(override_return_type(type_repr = "collections.abc.Coroutine[typing.Any, typing.Any, str]"))] + fn wait_disconnect<'py>(&self, py: Python<'py>) -> PyResult> { + let inner = self.inner.clone(); + pyo3_async_runtimes::tokio::future_into_py(py, async move { + let reason = inner.wait_disconnect().await; + Ok(reason) + }) + } + /// Get the commander subsystem fn commander(&self) -> Commander { Commander { From 9829365086a7f7e2f0fb525f11700300285f1bdc Mon Sep 17 00:00:00 2001 From: Rik Bouwmeester Date: Mon, 9 Mar 2026 16:06:21 +0100 Subject: [PATCH 2/2] Fix return type annotation for wait_disconnect method in Crazyflie class --- cflib2/_rust.pyi | 2 +- rust/src/crazyflie.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cflib2/_rust.pyi b/cflib2/_rust.pyi index 78e14eb..bcab1cc 100644 --- a/cflib2/_rust.pyi +++ b/cflib2/_rust.pyi @@ -324,7 +324,7 @@ class Crazyflie: r""" Disconnect from the Crazyflie """ - async def wait_disconnect(self) -> str: + async def wait_disconnect(self) -> builtins.str: r""" Wait for the Crazyflie to be disconnected diff --git a/rust/src/crazyflie.rs b/rust/src/crazyflie.rs index f30a96d..fdca6b2 100644 --- a/rust/src/crazyflie.rs +++ b/rust/src/crazyflie.rs @@ -137,7 +137,7 @@ impl Crazyflie { /// Wait for the Crazyflie to be disconnected /// /// Returns a human-readable string describing the reason for disconnection. - #[gen_stub(override_return_type(type_repr = "collections.abc.Coroutine[typing.Any, typing.Any, str]"))] + #[gen_stub(override_return_type(type_repr = "collections.abc.Coroutine[typing.Any, typing.Any, builtins.str]"))] fn wait_disconnect<'py>(&self, py: Python<'py>) -> PyResult> { let inner = self.inner.clone(); pyo3_async_runtimes::tokio::future_into_py(py, async move {