Skip to content

Commit 6948b2e

Browse files
chore: [pynumaflow-lite] lint and clippy checks in makefile (#344)
Signed-off-by: Vaibhav Tiwari <vaibhav.tiwari33@gmail.com>
1 parent d3aae0b commit 6948b2e

File tree

19 files changed

+73
-72
lines changed

19 files changed

+73
-72
lines changed

packages/pynumaflow-lite/Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,17 @@ test-rust:
4242

4343
clean:
4444
cargo clean
45+
46+
fmt:
47+
cargo fmt --all
48+
49+
.PHONY: lint
50+
lint: test-fmt clippy
51+
52+
.PHONY: test-fmt
53+
test-fmt:
54+
cargo fmt --all --check
55+
56+
.PHONY: clippy
57+
clippy:
58+
cargo clippy --workspace --all-targets --all-features -- -D warnings -A clippy::module_inception

packages/pynumaflow-lite/src/accumulate/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub(super) async fn start(
155155
// if not finished, abort it
156156
if !sig_handle.is_finished() {
157157
println!("Aborting signal handler");
158-
let _ = sig_handle.abort();
158+
sig_handle.abort();
159159
}
160160

161161
result

packages/pynumaflow-lite/src/batchmap/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub(super) async fn start(
9999
// if not finished, abort it
100100
if !sig_handle.is_finished() {
101101
println!("Aborting signal handler");
102-
let _ = sig_handle.abort();
102+
sig_handle.abort();
103103
}
104104

105105
result

packages/pynumaflow-lite/src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
114114
sub.setattr("__name__", fullname)?;
115115
py.import("sys")?
116116
.getattr("modules")?
117-
.set_item(fullname, &sub)?;
117+
.set_item(fullname, sub)?;
118118

119119
// Ensure it's importable as `pynumaflow_lite.batchmapper` as well
120120
let binding = m.getattr("batchmapper")?;
@@ -123,7 +123,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
123123
sub.setattr("__name__", fullname)?;
124124
py.import("sys")?
125125
.getattr("modules")?
126-
.set_item(fullname, &sub)?;
126+
.set_item(fullname, sub)?;
127127

128128
// Ensure it's importable as `pynumaflow_lite.mapstreamer` as well
129129
let binding = m.getattr("mapstreamer")?;
@@ -132,7 +132,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
132132
sub.setattr("__name__", fullname)?;
133133
py.import("sys")?
134134
.getattr("modules")?
135-
.set_item(fullname, &sub)?;
135+
.set_item(fullname, sub)?;
136136

137137
// Ensure it's importable as `pynumaflow_lite.reducer` as well
138138
let binding = m.getattr("reducer")?;
@@ -141,7 +141,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
141141
sub.setattr("__name__", fullname)?;
142142
py.import("sys")?
143143
.getattr("modules")?
144-
.set_item(fullname, &sub)?;
144+
.set_item(fullname, sub)?;
145145

146146
// Ensure it's importable as `pynumaflow_lite.session_reducer` as well
147147
let binding = m.getattr("session_reducer")?;
@@ -150,7 +150,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
150150
sub.setattr("__name__", fullname)?;
151151
py.import("sys")?
152152
.getattr("modules")?
153-
.set_item(fullname, &sub)?;
153+
.set_item(fullname, sub)?;
154154

155155
// Ensure it's importable as `pynumaflow_lite.reducestreamer` as well
156156
let binding = m.getattr("reducestreamer")?;
@@ -159,7 +159,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
159159
sub.setattr("__name__", fullname)?;
160160
py.import("sys")?
161161
.getattr("modules")?
162-
.set_item(fullname, &sub)?;
162+
.set_item(fullname, sub)?;
163163

164164
// Ensure it's importable as `pynumaflow_lite.accumulator` as well
165165
let binding = m.getattr("accumulator")?;
@@ -168,7 +168,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
168168
sub.setattr("__name__", fullname)?;
169169
py.import("sys")?
170170
.getattr("modules")?
171-
.set_item(fullname, &sub)?;
171+
.set_item(fullname, sub)?;
172172

173173
// Ensure it's importable as `pynumaflow_lite.sinker` as well
174174
let binding = m.getattr("sinker")?;
@@ -177,7 +177,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
177177
sub.setattr("__name__", fullname)?;
178178
py.import("sys")?
179179
.getattr("modules")?
180-
.set_item(fullname, &sub)?;
180+
.set_item(fullname, sub)?;
181181

182182
// Ensure it's importable as `pynumaflow_lite.sourcer` as well
183183
let binding = m.getattr("sourcer")?;
@@ -186,7 +186,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
186186
sub.setattr("__name__", fullname)?;
187187
py.import("sys")?
188188
.getattr("modules")?
189-
.set_item(fullname, &sub)?;
189+
.set_item(fullname, sub)?;
190190

191191
// Ensure it's importable as `pynumaflow_lite.sourcetransformer` as well
192192
let binding = m.getattr("sourcetransformer")?;
@@ -195,7 +195,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
195195
sub.setattr("__name__", fullname)?;
196196
py.import("sys")?
197197
.getattr("modules")?
198-
.set_item(fullname, &sub)?;
198+
.set_item(fullname, sub)?;
199199

200200
// Ensure it's importable as `pynumaflow_lite.sideinputer` as well
201201
let binding = m.getattr("sideinputer")?;
@@ -204,7 +204,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
204204
sub.setattr("__name__", fullname)?;
205205
py.import("sys")?
206206
.getattr("modules")?
207-
.set_item(fullname, &sub)?;
207+
.set_item(fullname, sub)?;
208208

209209
Ok(())
210210
}

packages/pynumaflow-lite/src/map/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub(super) async fn start(
8080
// if not finished, abort it
8181
if !sig_handle.is_finished() {
8282
println!("Aborting signal handler");
83-
let _ = sig_handle.abort();
83+
sig_handle.abort();
8484
}
8585

8686
result

packages/pynumaflow-lite/src/mapstream/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub(super) async fn start(
9595
// if not finished, abort it
9696
if !sig_handle.is_finished() {
9797
println!("Aborting signal handler");
98-
let _ = sig_handle.abort();
98+
sig_handle.abort();
9999
}
100100

101101
result

packages/pynumaflow-lite/src/pyiterables.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ use pyo3::{PyClass, exceptions::PyStopAsyncIteration, prelude::*};
1111
use tokio::sync::Mutex as AsyncMutex;
1212
use tokio::sync::mpsc;
1313

14+
type PyFuture = Pin<Box<dyn Future<Output = PyResult<Py<PyAny>>> + Send + 'static>>;
15+
1416
/// Stream over a Python AsyncIterator, yielding `M` as soon as each value is produced.
1517
/// `M` must be extractable from the Python object.
1618
///
@@ -24,7 +26,7 @@ pub struct PyAsyncIterStream<M> {
2426
event_loop: Arc<Py<PyAny>>,
2527
// In-flight future for the next item (converted from Python awaitable).
2628
#[pin]
27-
next_fut: Option<Pin<Box<dyn Future<Output = PyResult<Py<PyAny>>> + Send + 'static>>>,
29+
next_fut: Option<PyFuture>,
2830
// Phantom: we yield M
2931
_marker: std::marker::PhantomData<M>,
3032
}

packages/pynumaflow-lite/src/reduce/server.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,19 @@ impl reduce::Reducer for PyReduceRunner {
107107
// Ensure forwarder completes
108108
let _ = forwarder.await;
109109

110-
let messages = Python::attach(|py| {
110+
Python::attach(|py| {
111111
// Expect Messages; also allow a single Message for convenience
112112
if let Ok(msgs) = result.extract::<PyMessages>(py) {
113113
msgs.messages
114114
.into_iter()
115-
.map(|m| reduce::Message::from(m))
115+
.map(reduce::Message::from)
116116
.collect::<Vec<reduce::Message>>()
117117
} else if let Ok(single) = result.extract::<PyMessage>(py) {
118118
vec![single.into()]
119119
} else {
120120
vec![]
121121
}
122-
});
123-
124-
messages
122+
})
125123
}
126124
}
127125

@@ -144,20 +142,18 @@ pub(super) async fn start(
144142
let obj = py_creator.bind(py);
145143
// Check if it's a function or coroutine function using inspect module
146144
let inspect = py.import("inspect").ok()?;
147-
if let Ok(is_func) = inspect.call_method1("isfunction", (obj,)) {
148-
if let Ok(result) = is_func.extract::<bool>() {
149-
if result {
150-
return Some(true);
151-
}
152-
}
145+
if let Ok(is_func) = inspect.call_method1("isfunction", (obj,))
146+
&& let Ok(result) = is_func.extract::<bool>()
147+
&& result
148+
{
149+
return Some(true);
153150
}
154151
// Also check for coroutine function
155-
if let Ok(is_coro) = inspect.call_method1("iscoroutinefunction", (obj,)) {
156-
if let Ok(result) = is_coro.extract::<bool>() {
157-
if result {
158-
return Some(true);
159-
}
160-
}
152+
if let Ok(is_coro) = inspect.call_method1("iscoroutinefunction", (obj,))
153+
&& let Ok(result) = is_coro.extract::<bool>()
154+
&& result
155+
{
156+
return Some(true);
161157
}
162158
Some(false)
163159
})
@@ -194,7 +190,7 @@ pub(super) async fn start(
194190
// if not finished, abort it
195191
if !sig_handle.is_finished() {
196192
println!("Aborting signal handler");
197-
let _ = sig_handle.abort();
193+
sig_handle.abort();
198194
}
199195

200196
result

packages/pynumaflow-lite/src/reducestream/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ pub(super) async fn start(
164164
// if not finished, abort it
165165
if !sig_handle.is_finished() {
166166
println!("Aborting signal handler");
167-
let _ = sig_handle.abort();
167+
sig_handle.abort();
168168
}
169169

170170
result

packages/pynumaflow-lite/src/session_reduce/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub(super) async fn start(
198198
// if not finished, abort it
199199
if !sig_handle.is_finished() {
200200
println!("Aborting signal handler");
201-
let _ = sig_handle.abort();
201+
sig_handle.abort();
202202
}
203203

204204
result

0 commit comments

Comments
 (0)