Skip to content

Commit 56e2e00

Browse files
author
Andrew J Westlake
committed
Added clippy makefile, satisfied clippy's demands
1 parent f875309 commit 56e2e00

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
clippy:
3+
@touch src/lib.rs # Touching file to ensure that cargo clippy will re-check the project
4+
cargo clippy --tests -- -Dwarnings
5+
cargo clippy --tests -- -Dwarnings
6+
# for example in examples/*; do cargo clippy --manifest-path $$example/Cargo.toml -- -Dwarnings || exit 1; done

pytests/test_asyncio.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use pyo3::prelude::*;
55

66
use pyo3_asyncio::test::{parse_args, test_harness, Test};
77

8-
fn dump_err<'p>(py: Python<'p>) -> impl FnOnce(PyErr) + 'p {
8+
fn dump_err(py: Python<'_>) -> impl FnOnce(PyErr) + '_ {
99
move |e| {
1010
// We can't display Python exceptions via std::fmt::Display,
1111
// so print the error here manually.
@@ -34,12 +34,10 @@ fn test_async_sleep<'p>(
3434
})
3535
}
3636

37-
fn test_blocking_sleep() -> PyResult<()> {
37+
fn test_blocking_sleep() {
3838
println!("blocking sleep for 1s");
3939
thread::sleep(Duration::from_secs(1));
4040
println!("success");
41-
42-
Ok(())
4341
}
4442

4543
fn py_main(py: Python) -> PyResult<()> {
@@ -52,7 +50,10 @@ fn py_main(py: Python) -> PyResult<()> {
5250
test_harness(
5351
stream::iter(vec![
5452
Test::new_async("test_async_sleep".into(), test_async_sleep(py)?),
55-
Test::new_sync("test_blocking_sleep".into(), test_blocking_sleep),
53+
Test::new_sync("test_blocking_sleep".into(), || {
54+
test_blocking_sleep();
55+
Ok(())
56+
}),
5657
]),
5758
args,
5859
),

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl PyTaskCompleter {
142142
Err(e) => Err(e),
143143
};
144144

145-
if let Err(_) = self.tx.take().unwrap().send(result) {
145+
if self.tx.take().unwrap().send(result).is_err() {
146146
// cancellation is not an error
147147
}
148148

@@ -183,7 +183,7 @@ fn set_result(py: Python, future: &PyAny, result: PyResult<PyObject>) -> PyResul
183183
Ok(())
184184
}
185185

186-
fn dump_err<'p>(py: Python<'p>) -> impl FnOnce(PyErr) + 'p {
186+
fn dump_err(py: Python<'_>) -> impl FnOnce(PyErr) + '_ {
187187
move |e| {
188188
// We can't display Python exceptions via std::fmt::Display,
189189
// so print the error here manually.

0 commit comments

Comments
 (0)