From 775ce6cab7a5c867c34492b3fa59f33733d46a69 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 5 Aug 2026 15:48:14 +0000 Subject: [PATCH] Comment/docstring cleanup only, no functional changes - Fix stale claim in RustRuntime's doc: with skip_from_py_object, pyo3 does not clone-extract the pyclass; callers clone explicitly. - Fix changelog grammar and 'per-reactor' -> 'per-homeserver'. - Fix garden-path sentence in runtime.pyi docstring. - Minor punctuation fixes in new doc comments. Co-Authored-By: Claude Fable 5 --- changelog.d/20011.misc | 2 +- rust/src/homeserver.rs | 2 +- rust/src/reactor.rs | 2 +- rust/src/runtime.rs | 7 +++---- synapse/synapse_rust/runtime.pyi | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/changelog.d/20011.misc b/changelog.d/20011.misc index 859d619a95..9582106675 100644 --- a/changelog.d/20011.misc +++ b/changelog.d/20011.misc @@ -1 +1 @@ -Refactor Rust code have a single place to store per-reactor state. +Refactor the Rust code to have a single place to store per-homeserver state. diff --git a/rust/src/homeserver.rs b/rust/src/homeserver.rs index dbff7f5b32..74885d5e09 100644 --- a/rust/src/homeserver.rs +++ b/rust/src/homeserver.rs @@ -23,7 +23,7 @@ use crate::runtime::RustRuntime; /// The Python `HomeServer`, as seen from Rust. /// /// Like [`crate::reactor::Reactor`], this is a typed facade over a foreign -/// Python object: it does no validation of the object it wraps (the Python +/// Python object. It does no validation of the object it wraps (the Python /// side is type-checked by mypy), but it is the single place that names the /// `HomeServer` API surface that Rust code depends on. pub struct HomeServer(Py); diff --git a/rust/src/reactor.rs b/rust/src/reactor.rs index 2ac4d1a3be..db958d82b3 100644 --- a/rust/src/reactor.rs +++ b/rust/src/reactor.rs @@ -19,7 +19,7 @@ use pyo3::{call::PyCallArgs, intern, prelude::*}; /// The Twisted reactor, as seen from Rust. /// -/// A typed facade over a foreign Python object: it does no validation of the +/// A typed facade over a foreign Python object. It does no validation of the /// object it wraps (the Python side is type-checked by mypy), but it is the /// single place that names the Twisted API surface that Rust code depends /// on. diff --git a/rust/src/runtime.rs b/rust/src/runtime.rs index 51b9e587bf..7d6e329eec 100644 --- a/rust/src/runtime.rs +++ b/rust/src/runtime.rs @@ -125,9 +125,8 @@ impl Drop for RustRuntimeInner { /// /// One instance is constructed per homeserver by /// `HomeServer.get_rust_runtime()`. Rust classes that need it take it as a -/// constructor argument — pyo3 extracts a `#[pyclass]` that is `Clone` by -/// cloning, which here is just an `Arc` refcount bump — and hold their own -/// clone. Derefs to [`RustRuntimeInner`]. +/// constructor argument and store their own clone, which is just an `Arc` +/// refcount bump. Derefs to [`RustRuntimeInner`]. #[pyclass(frozen, skip_from_py_object)] #[derive(Clone)] pub struct RustRuntime { @@ -154,7 +153,7 @@ impl RustRuntime { }); // Shut the tokio runtime down when the reactor does. The trigger - // holds only a `Weak` reference: Twisted keeping the hook alive must + // holds only a `Weak` reference. Twisted keeping the hook alive must // not keep the runtime (nor, via it, the reactor) alive, as that // would be a reference cycle passing through a Rust field that // Python's GC cannot see into. diff --git a/synapse/synapse_rust/runtime.pyi b/synapse/synapse_rust/runtime.pyi index fb61ab81aa..b4aaaae907 100644 --- a/synapse/synapse_rust/runtime.pyi +++ b/synapse/synapse_rust/runtime.pyi @@ -5,7 +5,7 @@ class RustRuntime: Holds the tokio thread pool (started lazily on first use, shut down by a reactor shutdown trigger) and a handle to the reactor. Rust classes that - need either take this as a constructor argument; get it from + need them take this as a constructor argument. Get it from `hs.get_rust_runtime()`. """