ci: fix redundant import warnings on nightly (#3873)

This commit is contained in:
David Hewitt 2024-02-19 22:07:05 +00:00 committed by GitHub
parent 0bb9cab6d3
commit 4efc4b82a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
31 changed files with 23 additions and 50 deletions

View File

@ -206,7 +206,6 @@ assert hash_djb2('l50_50') == Number(-1152549421)
```rust ```rust
use std::collections::hash_map::DefaultHasher; use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use std::convert::TryInto;
use pyo3::exceptions::{PyValueError, PyZeroDivisionError}; use pyo3::exceptions::{PyValueError, PyZeroDivisionError};
use pyo3::prelude::*; use pyo3::prelude::*;

View File

@ -181,7 +181,7 @@ quickly testing your Python extensions.
```rust ```rust
use pyo3::prelude::*; use pyo3::prelude::*;
use pyo3::{PyCell, py_run}; use pyo3::py_run;
# fn main() { # fn main() {
#[pyclass] #[pyclass]
@ -228,7 +228,7 @@ to this function!
```rust ```rust
use pyo3::{ use pyo3::{
prelude::*, prelude::*,
types::{IntoPyDict, PyModule}, types::IntoPyDict,
}; };
# fn main() -> PyResult<()> { # fn main() -> PyResult<()> {
@ -437,7 +437,6 @@ Use context managers by directly invoking `__enter__` and `__exit__`.
```rust ```rust
use pyo3::prelude::*; use pyo3::prelude::*;
use pyo3::types::PyModule;
fn main() { fn main() {
Python::with_gil(|py| { Python::with_gil(|py| {

View File

@ -8,7 +8,6 @@ mod import_lib;
use std::{ use std::{
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
convert::AsRef,
env, env,
ffi::{OsStr, OsString}, ffi::{OsStr, OsString},
fmt::Display, fmt::Display,
@ -1785,7 +1784,6 @@ fn unescape(escaped: &str) -> Vec<u8> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::iter::FromIterator;
use target_lexicon::triple; use target_lexicon::triple;
use super::*; use super::*;

View File

@ -1097,7 +1097,6 @@ mod tests {
mod proptests { mod proptests {
use super::*; use super::*;
use crate::tests::common::CatchWarnings; use crate::tests::common::CatchWarnings;
use crate::types::any::PyAnyMethods;
use crate::types::IntoPyDict; use crate::types::IntoPyDict;
use proptest::prelude::*; use proptest::prelude::*;

View File

@ -112,7 +112,6 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::types::any::PyAnyMethods;
#[test] #[test]
fn test_hashbrown_hashmap_to_python() { fn test_hashbrown_hashmap_to_python() {

View File

@ -48,11 +48,11 @@
//! ``` //! ```
#[cfg(Py_LIMITED_API)] #[cfg(Py_LIMITED_API)]
use crate::types::bytes::PyBytesMethods; use crate::types::{bytes::PyBytesMethods, PyBytes};
use crate::{ use crate::{
ffi, ffi,
instance::Bound, instance::Bound,
types::{any::PyAnyMethods, *}, types::{any::PyAnyMethods, PyLong},
FromPyObject, IntoPy, Py, PyAny, PyObject, PyResult, Python, ToPyObject, FromPyObject, IntoPy, Py, PyAny, PyObject, PyResult, Python, ToPyObject,
}; };
@ -85,7 +85,7 @@ macro_rules! bigint_conversion {
let bytes = $to_bytes(self); let bytes = $to_bytes(self);
let bytes_obj = PyBytes::new_bound(py, &bytes); let bytes_obj = PyBytes::new_bound(py, &bytes);
let kwargs = if $is_signed > 0 { let kwargs = if $is_signed > 0 {
let kwargs = PyDict::new_bound(py); let kwargs = crate::types::PyDict::new_bound(py);
kwargs.set_item(crate::intern!(py, "signed"), true).unwrap(); kwargs.set_item(crate::intern!(py, "signed"), true).unwrap();
Some(kwargs) Some(kwargs)
} else { } else {
@ -224,7 +224,7 @@ fn int_to_py_bytes<'py>(
use crate::intern; use crate::intern;
let py = long.py(); let py = long.py();
let kwargs = if is_signed { let kwargs = if is_signed {
let kwargs = PyDict::new_bound(py); let kwargs = crate::types::PyDict::new_bound(py);
kwargs.set_item(intern!(py, "signed"), true)?; kwargs.set_item(intern!(py, "signed"), true)?;
Some(kwargs) Some(kwargs)
} else { } else {
@ -261,8 +261,6 @@ fn int_n_bits(long: &Bound<'_, PyLong>) -> PyResult<usize> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use self::{any::PyAnyMethods, dict::PyDictMethods};
use super::*; use super::*;
use crate::types::{PyDict, PyModule}; use crate::types::{PyDict, PyModule};
use indoc::indoc; use indoc::indoc;

View File

@ -108,10 +108,8 @@ impl IntoPy<PyObject> for Decimal {
mod test_rust_decimal { mod test_rust_decimal {
use super::*; use super::*;
use crate::err::PyErr; use crate::err::PyErr;
use crate::types::any::PyAnyMethods;
use crate::types::dict::PyDictMethods; use crate::types::dict::PyDictMethods;
use crate::types::PyDict; use crate::types::PyDict;
use rust_decimal::Decimal;
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
use proptest::prelude::*; use proptest::prelude::*;

View File

@ -97,7 +97,7 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::types::{any::PyAnyMethods, PyDict, PyList}; use crate::types::{PyDict, PyList};
#[test] #[test]
fn test_smallvec_into_py() { fn test_smallvec_into_py() {

View File

@ -111,7 +111,6 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::{IntoPy, PyObject, Python, ToPyObject};
use std::collections::{BTreeMap, HashMap}; use std::collections::{BTreeMap, HashMap};
#[test] #[test]

View File

@ -5,7 +5,6 @@ use crate::{
exceptions, ffi, Bound, FromPyObject, IntoPy, PyAny, PyErr, PyObject, PyResult, Python, exceptions, ffi, Bound, FromPyObject, IntoPy, PyAny, PyErr, PyObject, PyResult, Python,
ToPyObject, ToPyObject,
}; };
use std::convert::TryFrom;
use std::num::{ use std::num::{
NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize, NonZeroU128, NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize, NonZeroU128,
NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize,
@ -371,7 +370,6 @@ nonzero_int_impl!(NonZeroUsize, usize);
#[cfg(test)] #[cfg(test)]
mod test_128bit_integers { mod test_128bit_integers {
use super::*; use super::*;
use crate::types::any::PyAnyMethods;
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
use crate::types::PyDict; use crate::types::PyDict;

View File

@ -842,7 +842,7 @@ mod tests {
use super::*; use super::*;
use crate::types::any::PyAnyMethods; use crate::types::any::PyAnyMethods;
use crate::types::{IntoPyDict, PyDict}; use crate::types::{IntoPyDict, PyDict};
use crate::{PyErr, PyNativeType, Python}; use crate::{PyErr, PyNativeType};
import_exception!(socket, gaierror); import_exception!(socket, gaierror);
import_exception!(email.errors, MessageError); import_exception!(email.errors, MessageError);

View File

@ -1166,7 +1166,7 @@ impl<'unbound> Python<'unbound> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::types::{any::PyAnyMethods, IntoPyDict, PyDict, PyList}; use crate::types::{IntoPyDict, PyList};
use std::sync::Arc; use std::sync::Arc;
#[test] #[test]

View File

@ -17,7 +17,6 @@ use crate::{
use std::{ use std::{
borrow::Cow, borrow::Cow,
collections::HashMap, collections::HashMap,
convert::TryInto,
ffi::{CStr, CString}, ffi::{CStr, CString},
os::raw::{c_char, c_int, c_ulong, c_void}, os::raw::{c_char, c_int, c_ulong, c_void},
ptr, ptr,

View File

@ -275,7 +275,7 @@ impl Interned {
mod tests { mod tests {
use super::*; use super::*;
use crate::types::{any::PyAnyMethods, dict::PyDictMethods, PyDict}; use crate::types::{dict::PyDictMethods, PyDict};
#[test] #[test]
fn test_intern() { fn test_intern() {

View File

@ -1,8 +1,8 @@
use crate::ffi_ptr_ext::FfiPtrExt; use crate::ffi_ptr_ext::FfiPtrExt;
use crate::py_result_ext::PyResultExt; use crate::py_result_ext::PyResultExt;
use crate::{ffi, PyAny, PyNativeType}; use crate::{ffi, PyAny, PyNativeType};
use crate::{pyobject_native_type_core, PyErr, PyResult};
use crate::{Bound, Python}; use crate::{Bound, Python};
use crate::{PyErr, PyResult};
use std::ffi::{CStr, CString}; use std::ffi::{CStr, CString};
use std::os::raw::{c_char, c_int, c_void}; use std::os::raw::{c_char, c_int, c_void};

View File

@ -735,9 +735,7 @@ mod tests {
use super::*; use super::*;
#[cfg(not(PyPy))] #[cfg(not(PyPy))]
use crate::exceptions; use crate::exceptions;
#[cfg(not(PyPy))] use crate::types::PyTuple;
use crate::types::PyList;
use crate::{types::PyTuple, Python, ToPyObject};
use std::collections::{BTreeMap, HashMap}; use std::collections::{BTreeMap, HashMap};
#[test] #[test]

View File

@ -1,7 +1,6 @@
use crate::derive_utils::PyFunctionArguments; use crate::derive_utils::PyFunctionArguments;
use crate::ffi_ptr_ext::FfiPtrExt; use crate::ffi_ptr_ext::FfiPtrExt;
use crate::methods::PyMethodDefDestructor; use crate::methods::PyMethodDefDestructor;
use crate::prelude::*;
use crate::py_result_ext::PyResultExt; use crate::py_result_ext::PyResultExt;
use crate::types::capsule::PyCapsuleMethods; use crate::types::capsule::PyCapsuleMethods;
use crate::{ use crate::{
@ -9,6 +8,7 @@ use crate::{
impl_::pymethods::{self, PyMethodDef}, impl_::pymethods::{self, PyMethodDef},
types::{PyCapsule, PyDict, PyString, PyTuple}, types::{PyCapsule, PyDict, PyString, PyTuple},
}; };
use crate::{Bound, IntoPy, Py, PyAny, PyResult, Python};
use std::cell::UnsafeCell; use std::cell::UnsafeCell;
use std::ffi::CStr; use std::ffi::CStr;

View File

@ -1,4 +1,3 @@
use std::convert::TryInto;
use std::iter::FusedIterator; use std::iter::FusedIterator;
use crate::err::{self, PyResult}; use crate::err::{self, PyResult};

View File

@ -286,11 +286,7 @@ impl<'v> crate::PyTryFrom<'v> for PyMapping {
mod tests { mod tests {
use std::collections::HashMap; use std::collections::HashMap;
use crate::{ use crate::{exceptions::PyKeyError, types::PyTuple};
exceptions::PyKeyError,
types::{PyDict, PyTuple},
Python,
};
use super::*; use super::*;

View File

@ -514,10 +514,7 @@ impl IntoPy<Py<PyString>> for &'_ Py<PyString> {
#[cfg_attr(not(feature = "gil-refs"), allow(deprecated))] #[cfg_attr(not(feature = "gil-refs"), allow(deprecated))]
mod tests { mod tests {
use super::*; use super::*;
use crate::Python;
use crate::{PyObject, ToPyObject}; use crate::{PyObject, ToPyObject};
#[cfg(not(Py_LIMITED_API))]
use std::borrow::Cow;
#[test] #[test]
fn test_to_str_utf8() { fn test_to_str_utf8() {

View File

@ -116,8 +116,8 @@ impl<'py> PyTracebackMethods<'py> for Bound<'py, PyTraceback> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{ use crate::{
prelude::*, types::{any::PyAnyMethods, dict::PyDictMethods, traceback::PyTracebackMethods, PyDict},
types::{traceback::PyTracebackMethods, PyDict}, IntoPy, PyErr, Python,
}; };
#[test] #[test]

View File

@ -1,4 +1,3 @@
use std::convert::TryInto;
use std::iter::FusedIterator; use std::iter::FusedIterator;
use crate::ffi::{self, Py_ssize_t}; use crate::ffi::{self, Py_ssize_t};

View File

@ -1,7 +1,6 @@
#![cfg(feature = "macros")] #![cfg(feature = "macros")]
use pyo3::prelude::*; use pyo3::prelude::*;
use pyo3::ToPyObject;
#[macro_use] #[macro_use]
#[path = "../src/tests/common.rs"] #[path = "../src/tests/common.rs"]

View File

@ -1,7 +1,7 @@
#![cfg(feature = "macros")] #![cfg(feature = "macros")]
use pyo3::prelude::*; use pyo3::prelude::*;
use pyo3::{exceptions, py_run, PyErr, PyResult}; use pyo3::{exceptions, py_run};
use std::error::Error; use std::error::Error;
use std::fmt; use std::fmt;
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]

View File

@ -3,7 +3,7 @@
use pyo3::class::PyTraverseError; use pyo3::class::PyTraverseError;
use pyo3::class::PyVisit; use pyo3::class::PyVisit;
use pyo3::prelude::*; use pyo3::prelude::*;
use pyo3::{py_run, PyCell}; use pyo3::py_run;
use std::cell::Cell; use std::cell::Cell;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc; use std::sync::Arc;
@ -398,6 +398,7 @@ impl HijackedTraverse {
} }
} }
#[allow(dead_code)]
trait Traversable { trait Traversable {
fn __traverse__(&self, visit: PyVisit<'_>) -> Result<(), PyTraverseError>; fn __traverse__(&self, visit: PyVisit<'_>) -> Result<(), PyTraverseError>;
} }

View File

@ -177,7 +177,7 @@ except Exception as e:
mod inheriting_native_type { mod inheriting_native_type {
use super::*; use super::*;
use pyo3::exceptions::PyException; use pyo3::exceptions::PyException;
use pyo3::types::{IntoPyDict, PyDict}; use pyo3::types::PyDict;
#[cfg(not(PyPy))] #[cfg(not(PyPy))]
#[test] #[test]

View File

@ -3,7 +3,6 @@
use pyo3::prelude::*; use pyo3::prelude::*;
use pyo3::py_run; use pyo3::py_run;
use pyo3::types::{IntoPyDict, PyDict, PyList, PySet, PyString, PyTuple, PyType}; use pyo3::types::{IntoPyDict, PyDict, PyList, PySet, PyString, PyTuple, PyType};
use pyo3::PyCell;
#[path = "../src/tests/common.rs"] #[path = "../src/tests/common.rs"]
mod common; mod common;

View File

@ -2,7 +2,7 @@
use pyo3::exceptions::{PyAttributeError, PyIndexError, PyValueError}; use pyo3::exceptions::{PyAttributeError, PyIndexError, PyValueError};
use pyo3::types::{PyDict, PyList, PyMapping, PySequence, PySlice, PyType}; use pyo3::types::{PyDict, PyList, PyMapping, PySequence, PySlice, PyType};
use pyo3::{prelude::*, py_run, PyCell}; use pyo3::{prelude::*, py_run};
use std::{isize, iter}; use std::{isize, iter};
#[path = "../src/tests/common.rs"] #[path = "../src/tests/common.rs"]

View File

@ -3,7 +3,6 @@
//! Test slf: PyRef/PyMutRef<Self>(especially, slf.into::<Py>) works //! Test slf: PyRef/PyMutRef<Self>(especially, slf.into::<Py>) works
use pyo3::prelude::*; use pyo3::prelude::*;
use pyo3::types::{PyBytes, PyString}; use pyo3::types::{PyBytes, PyString};
use pyo3::PyCell;
use std::collections::HashMap; use std::collections::HashMap;
#[path = "../src/tests/common.rs"] #[path = "../src/tests/common.rs"]

View File

@ -2,7 +2,7 @@
use pyo3::prelude::*; use pyo3::prelude::*;
use pyo3::types::{PyDict, PyTuple}; use pyo3::types::{PyDict, PyTuple};
use pyo3::{types::PyType, wrap_pymodule, PyCell}; use pyo3::{types::PyType, wrap_pymodule};
#[path = "../src/tests/common.rs"] #[path = "../src/tests/common.rs"]
mod common; mod common;

View File

@ -1,8 +1,8 @@
#![cfg(feature = "macros")] #![cfg(feature = "macros")]
use pyo3::prelude::*; use pyo3::prelude::*;
use pyo3::py_run;
use pyo3::types::{PyDict, PyTuple}; use pyo3::types::{PyDict, PyTuple};
use pyo3::{py_run, PyCell};
use std::fmt; use std::fmt;