From 7eb9afbac20637831288104efe5a1396f06dfefa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Niederb=C3=BChl?= Date: Fri, 5 Jun 2020 13:51:15 +0200 Subject: [PATCH 1/3] Clean up Makefile --- Makefile | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 07dadcac1da..b4bacea9bc8 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,14 @@ -.PHONY: test test_py3 publish clippy lint fmt +.PHONY: test test_py publish clippy lint fmt # Constant used in clippy target CLIPPY_LINTS_TO_DENY := warnings -test: +test: lint test_py cargo test - ${MAKE} clippy - tox - for example in examples/*; do tox -e py -c $$example/tox.ini || exit 1; done -test_py3: - tox -e py3 - for example in examples/*; do tox -e py3 -c $$example/tox.ini || exit 1; done +test_py: + tox -e py + for example in examples/*; do tox -e py -c $$example/tox.ini || exit 1; done fmt: cargo fmt --all -- --check From 468bb765bbef30bb56d086950cbe61d9392c2249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Niederb=C3=BChl?= Date: Fri, 5 Jun 2020 13:51:51 +0200 Subject: [PATCH 2/3] Add checking of examples with clippy --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index b4bacea9bc8..897208f9d9b 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,7 @@ clippy: @touch src/lib.rs # Touching file to ensure that cargo clippy will re-check the project cargo clippy --all-features --all-targets -- \ $(addprefix -D ,${CLIPPY_LINTS_TO_DENY}) + for example in examples/*; do (cd $$example/; cargo clippy) || exit 1; done lint: fmt clippy @true From bcf48c0bd272276a5d5f23086d14b3b41ef1c304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Niederb=C3=BChl?= Date: Fri, 5 Jun 2020 13:53:01 +0200 Subject: [PATCH 3/3] Fix clippy lints --- examples/rustapi_module/src/datetime.rs | 1 + examples/word-count/src/lib.rs | 2 +- src/gil.rs | 1 + tests/test_pyself.rs | 1 - 4 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/rustapi_module/src/datetime.rs b/examples/rustapi_module/src/datetime.rs index cc20b6c67cf..14f4a071c10 100644 --- a/examples/rustapi_module/src/datetime.rs +++ b/examples/rustapi_module/src/datetime.rs @@ -114,6 +114,7 @@ fn get_delta_tuple<'p>(py: Python<'p>, delta: &PyDelta) -> &'p PyTuple { ) } +#[allow(clippy::too_many_arguments)] #[pyfunction] fn make_datetime<'p>( py: Python<'p>, diff --git a/examples/word-count/src/lib.rs b/examples/word-count/src/lib.rs index cf9b21e69fc..f06c08dac24 100644 --- a/examples/word-count/src/lib.rs +++ b/examples/word-count/src/lib.rs @@ -59,7 +59,7 @@ fn matches(word: &str, needle: &str) -> bool { } } } - return needle.next().is_none(); + needle.next().is_none() } /// Count the occurences of needle in line, case insensitive diff --git a/src/gil.rs b/src/gil.rs index ec3666e8512..bcff6258808 100644 --- a/src/gil.rs +++ b/src/gil.rs @@ -613,6 +613,7 @@ mod test { // Move obj to a thread which does not have the GIL, and clone it let t = std::thread::spawn(move || { // Cloning without GIL should not update reference count + #[allow(clippy::redundant_clone)] let _ = obj.clone(); assert_eq!(count, obj.get_refcnt()); diff --git a/tests/test_pyself.rs b/tests/test_pyself.rs index aabc5d9a4b5..57d5eaa4d40 100644 --- a/tests/test_pyself.rs +++ b/tests/test_pyself.rs @@ -1,5 +1,4 @@ //! Test slf: PyRef/PyMutRef(especially, slf.into::) works -use pyo3; use pyo3::prelude::*; use pyo3::types::{PyBytes, PyString}; use pyo3::{AsPyRef, PyCell, PyIterProtocol};