Skip to content

Commit

Permalink
Clippy and cargo check
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhly committed Oct 16, 2023
1 parent 38671ad commit a07abd4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
7 changes: 6 additions & 1 deletion pyo3-ffi/src/descrobject.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::methodobject::PyMethodDef;
use crate::object::{PyObject, PyTypeObject};
use crate::Py_ssize_t;
use crate::{PyObject_TypeCheck, Py_ssize_t};
use std::os::raw::{c_char, c_int, c_void};
use std::ptr;

Expand Down Expand Up @@ -68,6 +68,11 @@ extern "C" {
pub fn PyWrapper_New(arg1: *mut PyObject, arg2: *mut PyObject) -> *mut PyObject;
}

#[inline]
pub unsafe fn PyDictProxy_Check(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, std::ptr::addr_of_mut!(PyDictProxy_Type))
}

/// Represents the [PyMemberDef](https://docs.python.org/3/c-api/structures.html#c.PyMemberDef)
/// structure.
///
Expand Down
21 changes: 8 additions & 13 deletions src/types/mappingproxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,22 @@
use super::PyMapping;
use crate::err::PyResult;
use crate::types::dict::{IntoPyDict, PyDictItem};
#[cfg(all(test, not(PyPy)))]
use crate::types::dict::{PyDictItems, PyDictKeys, PyDictValues};
use crate::types::{PyAny, PyIterator, PyList, PySequence};
#[cfg(not(PyPy))]
use crate::{ffi, AsPyPointer, PyErr, PyTryFrom, Python, ToPyObject};
use std::os::raw::c_int;

#[allow(non_snake_case)]
unsafe fn PyDictProxy_Check(object: *mut crate::ffi::PyObject) -> c_int {
ffi::PyObject_TypeCheck(object, std::ptr::addr_of_mut!(ffi::PyDictProxy_Type))
}

/// Represents a Python `mappingproxy`.
#[repr(transparent)]
pub struct PyMappingProxy(PyAny);

#[cfg(not(PyPy))]
pyobject_native_type_core!(
PyMappingProxy,
pyobject_native_static_type_object!(ffi::PyDictProxy_Type),
#checkfunction=PyDictProxy_Check
#checkfunction=ffi::PyDictProxy_Check
);

#[allow(non_snake_case)]

impl PyMappingProxy {
/// Creates a mappingproxy from an object.
pub fn new<'py>(py: Python<'py>, elements: &'py PyMapping) -> PyResult<&'py PyMappingProxy> {
Expand Down Expand Up @@ -155,12 +149,13 @@ where
#[cfg(test)]
mod tests {
use super::*;
use crate::type_object::PyTypeInfo;
#[cfg(not(PyPy))]
use crate::Python;
use crate::{
exceptions::PyKeyError,
types::{PyInt, PyString, PyTuple},
types::{PyDictItems, PyDictKeys, PyDictValues, PyInt, PyString, PyTuple},
};
#[cfg(not(PyPy))]
use crate::{PyTypeInfo, Python};
use std::collections::{BTreeMap, HashMap};

#[test]
Expand Down

0 comments on commit a07abd4

Please sign in to comment.