Merge pull request #1559 from davidhewitt/tidy-clippy-allows

clippy: tidy up allow lints
This commit is contained in:
David Hewitt 2021-04-12 19:02:04 +01:00 committed by GitHub
commit 9cdec14454
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 98 additions and 111 deletions

View file

@ -162,7 +162,6 @@ macro_rules! py_binary_self_func {
$crate::callback_body!(py, {
let slf_ = py.from_borrowed_ptr::<$crate::PyCell<T>>(slf);
let arg = py.from_borrowed_ptr::<$crate::PyAny>(arg);
#[allow(clippy::needless_question_mark)]
call_operator_mut!(py, slf_, $f, arg).convert(py)?;
ffi::Py_INCREF(slf);
Ok::<_, $crate::err::PyErr>(slf)
@ -342,7 +341,7 @@ macro_rules! _call_impl {
$slf, $fn ;
(match $raw_arg.extract() {
Ok(res) => res,
_=> return Ok($py.NotImplemented().convert($py)?)
_=> return $py.NotImplemented().convert($py)
})
$(;$args)*
)

View file

@ -742,7 +742,6 @@ where
crate::callback_body!(py, {
let slf_cell = py.from_borrowed_ptr::<crate::PyCell<T>>(slf);
let other = py.from_borrowed_ptr::<crate::PyAny>(other);
#[allow(clippy::needless_question_mark)]
call_operator_mut!(py, slf_cell, __ipow__, other).convert(py)?;
ffi::Py_INCREF(slf);
Ok::<_, PyErr>(slf)

View file

@ -1,88 +1,4 @@
use crate::ffi::object::PyObject;
use crate::ffi::pyarena::*;
use crate::ffi::pythonrun::*;
use crate::ffi::PyCodeObject;
use std::os::raw::{c_char, c_int};
// skipped non-limited PyCF_MASK
// skipped non-limited PyCF_MASK_OBSOLETE
// skipped non-limited PyCF_SOURCE_IS_UTF8
// skipped non-limited PyCF_DONT_IMPLY_DEDENT
// skipped non-limited PyCF_ONLY_AST
// skipped non-limited PyCF_IGNORE_COOKIE
// skipped non-limited PyCF_TYPE_COMMENTS
// skipped non-limited PyCF_ALLOW_TOP_LEVEL_AWAIT
// skipped non-limited PyCF_COMPILE_MASK
// skipped non-limited PyCompilerFlags
// skipped non-limited _PyCompilerFlags_INIT
#[repr(C)]
#[derive(Copy, Clone)]
#[cfg(not(Py_LIMITED_API))]
pub struct PyFutureFeatures {
pub ff_features: c_int,
pub ff_lineno: c_int,
}
#[cfg(not(Py_LIMITED_API))]
pub const FUTURE_NESTED_SCOPES: &str = "nested_scopes";
#[cfg(not(Py_LIMITED_API))]
pub const FUTURE_GENERATORS: &str = "generators";
#[cfg(not(Py_LIMITED_API))]
pub const FUTURE_DIVISION: &str = "division";
#[cfg(not(Py_LIMITED_API))]
pub const FUTURE_ABSOLUTE_IMPORT: &str = "absolute_import";
#[cfg(not(Py_LIMITED_API))]
pub const FUTURE_WITH_STATEMENT: &str = "with_statement";
#[cfg(not(Py_LIMITED_API))]
pub const FUTURE_PRINT_FUNCTION: &str = "print_function";
#[cfg(not(Py_LIMITED_API))]
pub const FUTURE_UNICODE_LITERALS: &str = "unicode_literals";
#[cfg(not(Py_LIMITED_API))]
pub const FUTURE_BARRY_AS_BDFL: &str = "barry_as_FLUFL";
#[cfg(not(Py_LIMITED_API))]
pub const FUTURE_GENERATOR_STOP: &str = "generator_stop";
// skipped non-limited FUTURE_ANNOTATIONS
#[cfg(not(Py_LIMITED_API))]
extern "C" {
pub fn PyNode_Compile(arg1: *mut _node, arg2: *const c_char) -> *mut PyCodeObject;
pub fn PyAST_CompileEx(
_mod: *mut _mod,
filename: *const c_char,
flags: *mut PyCompilerFlags,
optimize: c_int,
arena: *mut PyArena,
) -> *mut PyCodeObject;
pub fn PyAST_CompileObject(
_mod: *mut _mod,
filename: *mut PyObject,
flags: *mut PyCompilerFlags,
optimize: c_int,
arena: *mut PyArena,
) -> *mut PyCodeObject;
pub fn PyFuture_FromAST(_mod: *mut _mod, filename: *const c_char) -> *mut PyFutureFeatures;
pub fn PyFuture_FromASTObject(
_mod: *mut _mod,
filename: *mut PyObject,
) -> *mut PyFutureFeatures;
// skipped non-limited _Py_Mangle
// skipped non-limited PY_INVALID_STACK_EFFECT
pub fn PyCompile_OpcodeStackEffect(opcode: c_int, oparg: c_int) -> c_int;
#[cfg(Py_3_8)]
pub fn PyCompile_OpcodeStackEffectWithJump(opcode: c_int, oparg: c_int, jump: c_int) -> c_int;
// skipped non-limited _PyASTOptimizeState
// skipped non-limited _PyAST_Optimize
}
use std::os::raw::c_int;
pub const Py_single_input: c_int = 256;
pub const Py_file_input: c_int = 257;

View file

@ -0,0 +1,74 @@
use crate::ffi::object::PyObject;
use crate::ffi::pyarena::*;
use crate::ffi::pythonrun::*;
use crate::ffi::PyCodeObject;
use std::os::raw::{c_char, c_int};
// skipped non-limited PyCF_MASK
// skipped non-limited PyCF_MASK_OBSOLETE
// skipped non-limited PyCF_SOURCE_IS_UTF8
// skipped non-limited PyCF_DONT_IMPLY_DEDENT
// skipped non-limited PyCF_ONLY_AST
// skipped non-limited PyCF_IGNORE_COOKIE
// skipped non-limited PyCF_TYPE_COMMENTS
// skipped non-limited PyCF_ALLOW_TOP_LEVEL_AWAIT
// skipped non-limited PyCF_COMPILE_MASK
// skipped non-limited PyCompilerFlags
// skipped non-limited _PyCompilerFlags_INIT
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyFutureFeatures {
pub ff_features: c_int,
pub ff_lineno: c_int,
}
pub const FUTURE_NESTED_SCOPES: &str = "nested_scopes";
pub const FUTURE_GENERATORS: &str = "generators";
pub const FUTURE_DIVISION: &str = "division";
pub const FUTURE_ABSOLUTE_IMPORT: &str = "absolute_import";
pub const FUTURE_WITH_STATEMENT: &str = "with_statement";
pub const FUTURE_PRINT_FUNCTION: &str = "print_function";
pub const FUTURE_UNICODE_LITERALS: &str = "unicode_literals";
pub const FUTURE_BARRY_AS_BDFL: &str = "barry_as_FLUFL";
pub const FUTURE_GENERATOR_STOP: &str = "generator_stop";
// skipped non-limited FUTURE_ANNOTATIONS
extern "C" {
pub fn PyNode_Compile(arg1: *mut _node, arg2: *const c_char) -> *mut PyCodeObject;
pub fn PyAST_CompileEx(
_mod: *mut _mod,
filename: *const c_char,
flags: *mut PyCompilerFlags,
optimize: c_int,
arena: *mut PyArena,
) -> *mut PyCodeObject;
pub fn PyAST_CompileObject(
_mod: *mut _mod,
filename: *mut PyObject,
flags: *mut PyCompilerFlags,
optimize: c_int,
arena: *mut PyArena,
) -> *mut PyCodeObject;
pub fn PyFuture_FromAST(_mod: *mut _mod, filename: *const c_char) -> *mut PyFutureFeatures;
pub fn PyFuture_FromASTObject(
_mod: *mut _mod,
filename: *mut PyObject,
) -> *mut PyFutureFeatures;
// skipped non-limited _Py_Mangle
// skipped non-limited PY_INVALID_STACK_EFFECT
pub fn PyCompile_OpcodeStackEffect(opcode: c_int, oparg: c_int) -> c_int;
#[cfg(Py_3_8)]
pub fn PyCompile_OpcodeStackEffectWithJump(opcode: c_int, oparg: c_int, jump: c_int) -> c_int;
// skipped non-limited _PyASTOptimizeState
// skipped non-limited _PyAST_Optimize
}

View file

@ -4,6 +4,7 @@ pub mod abstract_;
pub mod bytesobject;
pub mod ceval;
pub mod code;
pub mod compile;
#[cfg(not(PyPy))]
pub mod dictobject;
// skipped fileobject.h
@ -14,6 +15,7 @@ pub mod initconfig;
// skipped interpreteridobject.h
pub mod listobject;
pub mod object;
pub mod pydebug;
#[cfg(all(Py_3_8, not(PyPy)))]
pub mod pylifecycle;
@ -22,6 +24,7 @@ pub use self::abstract_::*;
pub use self::bytesobject::*;
pub use self::ceval::*;
pub use self::code::*;
pub use self::compile::*;
#[cfg(not(PyPy))]
pub use self::dictobject::*;
pub use self::frameobject::*;
@ -29,5 +32,6 @@ pub use self::frameobject::*;
pub use self::initconfig::*;
pub use self::listobject::*;
pub use self::object::*;
pub use self::pydebug::*;
#[cfg(all(Py_3_8, not(PyPy)))]
pub use self::pylifecycle::*;

View file

@ -1,5 +1,3 @@
#![cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))]
//! FFI bindings to the functions and structs defined in `datetime.h`
//!
//! This is the unsafe thin wrapper around the [CPython C API](https://docs.python.org/3/c-api/datetime.html),

View file

@ -1,9 +1,9 @@
use crate::ffi::object::*;
use crate::ffi::pyport::Py_ssize_t;
use libc::size_t;
use std::os::raw::{
c_char, c_double, c_int, c_long, c_longlong, c_uchar, c_ulong, c_ulonglong, c_void,
};
#[cfg(not(Py_LIMITED_API))]
use std::os::raw::c_uchar;
use std::os::raw::{c_char, c_double, c_int, c_long, c_longlong, c_ulong, c_ulonglong, c_void};
opaque_struct!(PyLongObject);

View file

@ -1,6 +1,11 @@
#![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(clippy::inline_always))]
//! Raw ffi declarations for the C interface of Python.
#![allow(
non_camel_case_types,
non_snake_case,
non_upper_case_globals,
clippy::upper_case_acronyms,
clippy::missing_safety_doc
)]
// Until `extern type` is stabilized, use the recommended approach to
// model opaque types:
@ -50,7 +55,6 @@ pub use self::objimpl::*;
pub use self::osmodule::*;
pub use self::pyarena::*;
pub use self::pycapsule::*;
pub use self::pydebug::*;
pub use self::pyerrors::*;
pub use self::pyframe::*;
pub use self::pyhash::*;
@ -163,7 +167,6 @@ mod pyport;
// mod pytime; contains nothing of interest
mod objimpl;
mod pydebug;
mod pyhash;
mod pymem;
mod typeslots;

View file

@ -1,9 +1,9 @@
use crate::ffi::object::*;
#[cfg(not(Py_LIMITED_API))]
use crate::ffi::pyarena::PyArena;
#[cfg(not(Py_LIMITED_API))]
use libc::FILE;
use std::os::raw::{c_char, c_int};
use std::ptr;
// TODO: PyCF_MASK etc. constants
@ -162,10 +162,10 @@ extern "C" {
#[cfg(any(not(Py_LIMITED_API), PyPy))]
pub unsafe fn Py_CompileString(string: *const c_char, p: *const c_char, s: c_int) -> *mut PyObject {
#[cfg(not(PyPy))]
return Py_CompileStringExFlags(string, p, s, ptr::null_mut(), -1);
return Py_CompileStringExFlags(string, p, s, std::ptr::null_mut(), -1);
#[cfg(PyPy)]
Py_CompileStringFlags(string, p, s, ptr::null_mut())
Py_CompileStringFlags(string, p, s, std::ptr::null_mut())
}
extern "C" {

View file

@ -170,9 +170,6 @@ mod conversions;
pub mod derive_utils;
mod err;
pub mod exceptions;
/// Raw ffi declarations for the c interface of python
#[allow(clippy::upper_case_acronyms)]
#[allow(clippy::missing_safety_doc)]
pub mod ffi;
pub mod freelist;
mod gil;

View file

@ -3,8 +3,6 @@
//! 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::err::PyResult;
use crate::ffi;
#[cfg(PyPy)]
@ -130,6 +128,7 @@ pyobject_native_type!(
);
impl PyDateTime {
#[allow(clippy::clippy::too_many_arguments)]
pub fn new<'p>(
py: Python<'p>,
year: i32,
@ -157,9 +156,10 @@ impl PyDateTime {
}
}
#[cfg(not(PyPy))]
/// Alternate constructor that takes a `fold` parameter. A `true` value for this parameter
/// signifies a leap second
#[cfg(not(PyPy))]
#[allow(clippy::clippy::too_many_arguments)]
pub fn new_with_fold<'p>(
py: Python<'p>,
year: i32,

View file

@ -49,7 +49,7 @@ impl IntoPy<PyObject> for f64 {
impl<'source> FromPyObject<'source> for f64 {
// PyFloat_AsDouble returns -1.0 upon failure
#![cfg_attr(feature = "cargo-clippy", allow(clippy::float_cmp))]
#![allow(clippy::float_cmp)]
fn extract(obj: &'source PyAny) -> PyResult<Self> {
let v = unsafe { ffi::PyFloat_AsDouble(obj.as_ptr()) };

View file

@ -60,13 +60,11 @@ pyobject_native_var_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(clippy::cast_lossless))]
fn to_object(&self, py: Python) -> PyObject {
unsafe { PyObject::from_owned_ptr(py, ffi::PyLong_FromLong(*self as c_long)) }
}
}
impl IntoPy<PyObject> for $rust_type {
#![cfg_attr(feature = "cargo-clippy", allow(clippy::cast_lossless))]
fn into_py(self, py: Python) -> PyObject {
unsafe { PyObject::from_owned_ptr(py, ffi::PyLong_FromLong(self as c_long)) }
}

View file

@ -3,7 +3,6 @@
use pyo3::prelude::*;
use pyo3::types::IntoPyDict;
#[allow(clippy::trivially_copy_pass_by_ref)]
fn _get_subclasses<'p>(
py: &'p Python,
py_type: &str,