diff --git a/src/class/buffer.rs b/src/class/buffer.rs index fac41b91..bf66413f 100644 --- a/src/class/buffer.rs +++ b/src/class/buffer.rs @@ -54,6 +54,7 @@ where T: PyBufferProtocol<'p>, { #[inline] + #[allow(clippy::needless_update)] // For python 2 it's not useless fn tp_as_buffer() -> Option { Some(ffi::PyBufferProcs { bf_getbuffer: Self::cb_bf_getbuffer(), diff --git a/src/ffi/datetime.rs b/src/ffi/datetime.rs index b9fe813b..459d24e4 100644 --- a/src/ffi/datetime.rs +++ b/src/ffi/datetime.rs @@ -1,4 +1,4 @@ -#![cfg_attr(feature = "cargo-clippy", allow(type_complexity))] +#![cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] //! FFI bindings to the functions and structs defined in `datetime.h` //! diff --git a/src/ffi3/longobject.rs b/src/ffi3/longobject.rs index 5707dd80..5df8d33b 100644 --- a/src/ffi3/longobject.rs +++ b/src/ffi3/longobject.rs @@ -5,10 +5,10 @@ use std::os::raw::{ c_char, c_double, c_int, c_long, c_longlong, c_uchar, c_ulong, c_ulonglong, c_void, }; +/// In the python doc this opaque, but we know we can cast, so we make clippy happy by telling +/// it that it actually looks like a PyObject #[repr(C)] -pub struct PyLongObject { - _private: [u8; 0], -} +pub struct PyLongObject(PyObject); #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { diff --git a/src/ffi3/mod.rs b/src/ffi3/mod.rs index 8c6b68dd..9221c81e 100644 --- a/src/ffi3/mod.rs +++ b/src/ffi3/mod.rs @@ -1,7 +1,7 @@ //! Rust FFI declarations for Python 3 #![allow(non_camel_case_types, non_snake_case, non_upper_case_globals)] #![cfg_attr(Py_LIMITED_API, allow(unused_imports))] -#![cfg_attr(feature="cargo-clippy", allow(inline_always))] +#![cfg_attr(feature="cargo-clippy", allow(clippy::inline_always))] pub use self::pymem::*; pub use self::pyport::*; diff --git a/src/object.rs b/src/object.rs index 87b0e01c..c4b310d5 100644 --- a/src/object.rs +++ b/src/object.rs @@ -176,7 +176,7 @@ impl PyObject { /// Calls the object. /// This is equivalent to the Python expression: 'self(*args, **kwargs)' - pub fn call(&self, py: Python, args: A, kwargs: Option) -> PyResult + pub fn call(&self, py: Python, args: A, kwargs: Option<&PyDict>) -> PyResult where A: IntoPyTuple, { diff --git a/src/typeob.rs b/src/typeob.rs index 5847bb5f..d2979668 100644 --- a/src/typeob.rs +++ b/src/typeob.rs @@ -85,7 +85,7 @@ pub const PY_TYPE_FLAG_DICT: usize = 1 << 3; /// impl MyClass { /// #[new] /// fn __new__(obj: &PyRawObject) -> PyResult<()> { -/// obj.init(|| MyClass { }) +/// obj.init(|| MyClass { }) /// } /// } /// ``` @@ -149,7 +149,7 @@ impl PyRawObject { let value = f(); unsafe { - let ptr = (self.ptr as *mut u8).offset(T::OFFSET) as *mut T; + let ptr = self.ptr.offset(T::OFFSET) as *mut T; std::ptr::write(ptr, value); } Ok(()) diff --git a/src/types/complex.rs b/src/types/complex.rs index 030486be..4d5c81c0 100644 --- a/src/types/complex.rs +++ b/src/types/complex.rs @@ -14,7 +14,7 @@ pyobject_native_type!(PyComplex, ffi::PyComplex_Type, ffi::PyComplex_Check); impl PyComplex { /// Creates a new Python `PyComplex` object, from its real and imaginary values. - pub fn from_doubles<'p>(py: Python<'p>, real: c_double, imag: c_double) -> &'p PyComplex { + pub fn from_doubles(py: Python, real: c_double, imag: c_double) -> &PyComplex { unsafe { let ptr = ffi::PyComplex_FromDoubles(real, imag); py.from_owned_ptr(ptr) diff --git a/src/types/datetime.rs b/src/types/datetime.rs index 61320c7f..e9828336 100644 --- a/src/types/datetime.rs +++ b/src/types/datetime.rs @@ -2,6 +2,9 @@ //! //! For more details about these types, see the [Python //! documentation](https://docs.python.org/3/library/datetime.html) + +#![allow(clippy::too_many_arguments)] + use crate::conversion::ToPyObject; use crate::err::PyResult; use crate::ffi; diff --git a/src/types/floatob.rs b/src/types/floatob.rs index c1cc501e..fd3e7309 100644 --- a/src/types/floatob.rs +++ b/src/types/floatob.rs @@ -51,7 +51,7 @@ impl IntoPyObject for f64 { impl<'source> FromPyObject<'source> for f64 { // PyFloat_AsDouble returns -1.0 upon failure - #![cfg_attr(feature = "cargo-clippy", allow(float_cmp))] + #![cfg_attr(feature = "cargo-clippy", allow(clippy::float_cmp))] fn extract(obj: &'source PyObjectRef) -> PyResult { let v = unsafe { ffi::PyFloat_AsDouble(obj.as_ptr()) }; diff --git a/src/types/num3.rs b/src/types/num3.rs index 4e158ebc..ce3b9e7b 100644 --- a/src/types/num3.rs +++ b/src/types/num3.rs @@ -30,7 +30,7 @@ pyobject_native_type!(PyLong, ffi::PyLong_Type, ffi::PyLong_Check); macro_rules! int_fits_c_long ( ($rust_type:ty) => ( impl ToPyObject for $rust_type { - #![cfg_attr(feature="cargo-clippy", allow(cast_lossless))] + #![cfg_attr(feature="cargo-clippy", allow(clippy::cast_lossless))] fn to_object(&self, py: Python) -> PyObject { unsafe { PyObject::from_owned_ptr_or_panic(py, ffi::PyLong_FromLong(*self as c_long)) @@ -38,7 +38,7 @@ macro_rules! int_fits_c_long ( } } impl IntoPyObject for $rust_type { - #![cfg_attr(feature="cargo-clippy", allow(cast_lossless))] + #![cfg_attr(feature="cargo-clippy", allow(clippy::cast_lossless))] fn into_object(self, py: Python) -> PyObject { unsafe { PyObject::from_owned_ptr_or_panic(py, ffi::PyLong_FromLong(self as c_long)) diff --git a/src/types/num_common.rs b/src/types/num_common.rs index 789e11a5..faf49909 100644 --- a/src/types/num_common.rs +++ b/src/types/num_common.rs @@ -5,7 +5,7 @@ use std::os::raw::c_int; use crate::err::{PyErr, PyResult}; use crate::python::Python; -pub(super) fn err_if_invalid_value( +pub(super) fn err_if_invalid_value( py: Python, invalid_value: T, actual_value: T,