diff --git a/src/class/mod.rs b/src/class/mod.rs index 3bae45ac..79fb43c6 100644 --- a/src/class/mod.rs +++ b/src/class/mod.rs @@ -5,7 +5,6 @@ #[macro_use] mod macros; -pub mod pyasync; pub mod basic; pub mod buffer; pub mod context; @@ -15,9 +14,9 @@ pub mod iter; pub mod mapping; pub mod methods; pub mod number; +pub mod pyasync; pub mod sequence; -pub use self::pyasync::PyAsyncProtocol; pub use self::basic::PyObjectProtocol; pub use self::buffer::PyBufferProtocol; pub use self::context::PyContextProtocol; @@ -25,6 +24,7 @@ pub use self::descr::PyDescrProtocol; pub use self::iter::PyIterProtocol; pub use self::mapping::PyMappingProtocol; pub use self::number::PyNumberProtocol; +pub use self::pyasync::PyAsyncProtocol; pub use self::sequence::PySequenceProtocol; pub use self::gc::{PyGCProtocol, PyTraverseError, PyVisit}; diff --git a/src/class/sequence.rs b/src/class/sequence.rs index 1a4a3e83..b6509ea6 100644 --- a/src/class/sequence.rs +++ b/src/class/sequence.rs @@ -9,9 +9,9 @@ use crate::err::{PyErr, PyResult}; use crate::ffi; use crate::objectprotocol::ObjectProtocol; use crate::python::Python; -use std::os::raw::c_int; use crate::typeob::PyTypeInfo; use crate::types::{exceptions, PyObjectRef}; +use std::os::raw::c_int; /// Sequece interface #[allow(unused_variables)] diff --git a/src/derive_utils.rs b/src/derive_utils.rs index d000b23d..9c390ea1 100644 --- a/src/derive_utils.rs +++ b/src/derive_utils.rs @@ -9,11 +9,11 @@ use crate::err::PyResult; use crate::exceptions::TypeError; use crate::ffi; use crate::init_once; -use std::ptr; use crate::types::PyModule; use crate::types::{PyDict, PyObjectRef, PyString, PyTuple}; use crate::GILPool; use crate::Python; +use std::ptr; #[derive(Debug)] /// Description of a python parameter; used for `parse_args()`. diff --git a/src/ffi3/ceval.rs b/src/ffi3/ceval.rs index 239e61f1..ebfbca36 100644 --- a/src/ffi3/ceval.rs +++ b/src/ffi3/ceval.rs @@ -45,7 +45,8 @@ extern "C" { // TODO: Py_EnterRecursiveCall etc. #[cfg(Py_3_6)] -pub type _PyFrameEvalFunction = extern "C" fn(*mut crate::ffi3::PyFrameObject, c_int) -> *mut PyObject; +pub type _PyFrameEvalFunction = + extern "C" fn(*mut crate::ffi3::PyFrameObject, c_int) -> *mut PyObject; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { @@ -54,7 +55,10 @@ extern "C" { pub fn PyEval_GetCallStats(arg1: *mut PyObject) -> *mut PyObject; pub fn PyEval_EvalFrame(arg1: *mut crate::ffi3::PyFrameObject) -> *mut PyObject; #[cfg(Py_3_6)] - pub fn _PyEval_EvalFrameDefault(arg1: *mut crate::ffi3::PyFrameObject, exc: c_int) -> *mut PyObject; + pub fn _PyEval_EvalFrameDefault( + arg1: *mut crate::ffi3::PyFrameObject, + exc: c_int, + ) -> *mut PyObject; #[cfg(Py_3_6)] pub fn _PyEval_RequestCodeExtraIndex(func: FreeFunc) -> c_int; pub fn PyEval_EvalFrameEx(f: *mut crate::ffi3::PyFrameObject, exc: c_int) -> *mut PyObject; diff --git a/src/freelist.rs b/src/freelist.rs index 916e5a20..4e6d0414 100644 --- a/src/freelist.rs +++ b/src/freelist.rs @@ -5,9 +5,9 @@ use crate::err::PyResult; use crate::ffi; use crate::python::Python; +use crate::typeob::{pytype_drop, PyObjectAlloc, PyTypeInfo}; use std::mem; use std::os::raw::c_void; -use crate::typeob::{pytype_drop, PyObjectAlloc, PyTypeInfo}; /// Implementing this trait for custom class adds free allocation list to class. /// The performance improvement applies to types that are often created and deleted in a row, diff --git a/src/objectprotocol.rs b/src/objectprotocol.rs index 9ecc0450..c249f1f6 100644 --- a/src/objectprotocol.rs +++ b/src/objectprotocol.rs @@ -6,11 +6,11 @@ use crate::ffi; use crate::instance::PyObjectWithToken; use crate::object::PyObject; use crate::python::{IntoPyPointer, Python, ToPyPointer}; +use crate::typeob::PyTypeInfo; +use crate::types::{PyDict, PyIterator, PyObjectRef, PyString, PyTuple, PyType}; use std; use std::cmp::Ordering; use std::os::raw::c_int; -use crate::typeob::PyTypeInfo; -use crate::types::{PyDict, PyIterator, PyObjectRef, PyString, PyTuple, PyType}; /// Python object model helper methods pub trait ObjectProtocol { diff --git a/src/python.rs b/src/python.rs index 77851ead..cd316f88 100644 --- a/src/python.rs +++ b/src/python.rs @@ -8,13 +8,13 @@ use crate::ffi; use crate::instance::{AsPyRef, Py, PyToken}; use crate::object::PyObject; use crate::pythonrun::{self, GILGuard}; +use crate::typeob::PyTypeCreate; +use crate::typeob::{PyTypeInfo, PyTypeObject}; +use crate::types::{PyDict, PyModule, PyObjectRef, PyType}; use std; use std::ffi::CString; use std::marker::PhantomData; use std::os::raw::c_int; -use crate::typeob::PyTypeCreate; -use crate::typeob::{PyTypeInfo, PyTypeObject}; -use crate::types::{PyDict, PyModule, PyObjectRef, PyType}; /// Marker type that indicates that the GIL is currently held. /// diff --git a/src/pythonrun.rs b/src/pythonrun.rs index dafe0947..a37aefa3 100644 --- a/src/pythonrun.rs +++ b/src/pythonrun.rs @@ -1,9 +1,9 @@ // Copyright (c) 2017-present PyO3 Project and Contributors use crate::ffi; use crate::python::Python; +use crate::types::PyObjectRef; use spin; use std::{any, marker, rc, sync}; -use crate::types::PyObjectRef; static START: sync::Once = sync::ONCE_INIT; static START_PYO3: sync::Once = sync::ONCE_INIT; diff --git a/src/typeob.rs b/src/typeob.rs index b64c7710..9cffc33a 100644 --- a/src/typeob.rs +++ b/src/typeob.rs @@ -7,14 +7,14 @@ use crate::err::{PyErr, PyResult}; use crate::instance::{Py, PyObjectWithToken, PyToken}; use crate::python::ToPyPointer; use crate::python::{IntoPyPointer, Python}; +use crate::types::PyObjectRef; +use crate::types::PyType; +use crate::{class, ffi, pythonrun}; use std; use std::collections::HashMap; use std::ffi::CString; use std::mem; use std::os::raw::c_void; -use crate::types::PyObjectRef; -use crate::types::PyType; -use crate::{class, ffi, pythonrun}; /// Python type information. pub trait PyTypeInfo { diff --git a/src/types/datetime.rs b/src/types/datetime.rs index 6df27435..61320c7f 100644 --- a/src/types/datetime.rs +++ b/src/types/datetime.rs @@ -24,9 +24,9 @@ use crate::ffi::{ use crate::instance::Py; use crate::object::PyObject; use crate::python::{Python, ToPyPointer}; +use crate::types::PyTuple; use std::os::raw::c_int; use std::ptr; -use crate::types::PyTuple; /// Access traits diff --git a/src/types/dict.rs b/src/types/dict.rs index 27228908..887e382d 100644 --- a/src/types/dict.rs +++ b/src/types/dict.rs @@ -6,9 +6,9 @@ use crate::ffi; use crate::instance::PyObjectWithToken; use crate::object::PyObject; use crate::python::{IntoPyPointer, Python, ToPyPointer}; +use crate::types::{PyList, PyObjectRef}; use std; use std::{cmp, collections, hash, mem}; -use crate::types::{PyList, PyObjectRef}; /// Represents a Python `dict`. #[repr(transparent)] @@ -275,10 +275,10 @@ mod test { use crate::conversion::{IntoPyObject, PyTryFrom, ToPyObject}; use crate::instance::AsPyRef; use crate::python::Python; - use std::collections::{BTreeMap, HashMap}; use crate::types::dict::IntoPyDict; use crate::types::{PyDict, PyList, PyTuple}; use crate::ObjectProtocol; + use std::collections::{BTreeMap, HashMap}; #[test] fn test_new() { diff --git a/src/types/exceptions.rs b/src/types/exceptions.rs index 08aad1d1..e4c55e2c 100644 --- a/src/types/exceptions.rs +++ b/src/types/exceptions.rs @@ -7,11 +7,11 @@ use crate::err::{PyErr, PyResult}; use crate::ffi; use crate::instance::Py; use crate::python::{Python, ToPyPointer}; +use crate::typeob::PyTypeObject; +use crate::types::{PyObjectRef, PyTuple, PyType}; use std::ffi::CStr; use std::os::raw::c_char; use std::{self, ops}; -use crate::typeob::PyTypeObject; -use crate::types::{PyObjectRef, PyTuple, PyType}; // Copyright (c) 2017-present PyO3 Project and Contributors diff --git a/src/types/floatob.rs b/src/types/floatob.rs index f974614a..28cc2d91 100644 --- a/src/types/floatob.rs +++ b/src/types/floatob.rs @@ -9,10 +9,10 @@ use crate::instance::{Py, PyObjectWithToken}; use crate::object::PyObject; use crate::objectprotocol::ObjectProtocol; use crate::python::{Python, ToPyPointer}; -use std::os::raw::c_double; use crate::types::PyObjectRef; use crate::FromPyObject; use crate::PyResult; +use std::os::raw::c_double; /// Represents a Python `float` object. /// diff --git a/src/types/iterator.rs b/src/types/iterator.rs index b46074a9..c5483801 100644 --- a/src/types/iterator.rs +++ b/src/types/iterator.rs @@ -71,7 +71,8 @@ mod tests { use crate::objectprotocol::ObjectProtocol; use crate::python::Python; use crate::pythonrun::GILPool; - use crate::types::{PyList, PyObjectRef}; + use crate::types::{PyDict, PyList, PyObjectRef}; + use crate::GILGuard; #[test] fn vec_iter() { @@ -135,13 +136,6 @@ mod tests { } assert_eq!(count, none.get_refcnt()); } -} - -#[cfg(test)] -mod test { - use crate::objectprotocol::ObjectProtocol; - use crate::GILGuard; - use crate::types::PyDict; #[test] fn fibonacci_generator() { diff --git a/src/types/module.rs b/src/types/module.rs index 61ea7cbc..64f5ed5b 100644 --- a/src/types/module.rs +++ b/src/types/module.rs @@ -9,11 +9,11 @@ use crate::instance::PyObjectWithToken; use crate::object::PyObject; use crate::objectprotocol::ObjectProtocol; use crate::python::{Python, ToPyPointer}; +use crate::typeob::{initialize_type, PyTypeInfo}; +use crate::types::{exceptions, PyDict, PyObjectRef, PyType}; use std::ffi::{CStr, CString}; use std::os::raw::c_char; use std::str; -use crate::typeob::{initialize_type, PyTypeInfo}; -use crate::types::{exceptions, PyDict, PyObjectRef, PyType}; /// Represents a Python `module` object. #[repr(transparent)] diff --git a/src/types/num3.rs b/src/types/num3.rs index 723ddcb2..9cc4652c 100644 --- a/src/types/num3.rs +++ b/src/types/num3.rs @@ -12,9 +12,9 @@ use crate::ffi; use crate::instance::PyObjectWithToken; use crate::object::PyObject; use crate::python::{Python, ToPyPointer}; +use crate::types::{exceptions, PyObjectRef}; use std::i64; use std::os::raw::{c_long, c_uchar}; -use crate::types::{exceptions, PyObjectRef}; /// Represents a Python `int` object. /// diff --git a/src/types/num_common.rs b/src/types/num_common.rs index ee9989e0..82f5f26b 100644 --- a/src/types/num_common.rs +++ b/src/types/num_common.rs @@ -188,8 +188,8 @@ mod test { fn test_u128_overflow() { use crate::ffi; use crate::object::PyObject; - use std::os::raw::c_uchar; use crate::types::exceptions; + use std::os::raw::c_uchar; let gil = Python::acquire_gil(); let py = gil.python(); let overflow_bytes: [c_uchar; 20] = [255; 20]; diff --git a/src/types/stringutils.rs b/src/types/stringutils.rs index 7385871d..4a672626 100644 --- a/src/types/stringutils.rs +++ b/src/types/stringutils.rs @@ -3,9 +3,9 @@ use crate::err::PyResult; use crate::instance::PyObjectWithToken; use crate::object::PyObject; use crate::python::Python; -use std::borrow::Cow; use crate::types::{PyObjectRef, PyString}; use crate::FromPyObject; +use std::borrow::Cow; /// Converts Rust `str` to Python object. /// See `PyString::new` for details on the conversion. diff --git a/src/types/tuple.rs b/src/types/tuple.rs index c8955f03..e1a1da74 100644 --- a/src/types/tuple.rs +++ b/src/types/tuple.rs @@ -7,8 +7,8 @@ use crate::ffi::{self, Py_ssize_t}; use crate::instance::{AsPyRef, Py, PyObjectWithToken}; use crate::object::PyObject; use crate::python::{IntoPyPointer, Python, ToPyPointer}; -use std::slice; use crate::types::PyObjectRef; +use std::slice; /// Represents a Python `tuple` object. #[repr(transparent)] @@ -269,9 +269,9 @@ mod test { use crate::instance::AsPyRef; use crate::objectprotocol::ObjectProtocol; use crate::python::Python; - use std::collections::HashSet; use crate::types::PyObjectRef; use crate::types::PyTuple; + use std::collections::HashSet; #[test] fn test_new() {