Address Clippy lints
Some checks failed
CI / Formatting (push) Successful in 39s
CI / Clippy (push) Failing after 59s
CI / Build (push) Successful in 1m28s
CI / Python tests (push) Successful in 38s
CI / Rust tests (push) Successful in 1m18s

This commit is contained in:
Michael Bradley 2025-02-23 09:50:20 -05:00
parent b1d49624d4
commit 8ed5e410ff
Signed by: MichaelBradley
SSH key fingerprint: SHA256:cj/YZ5VT+QOKncqSkx+ibKTIn0Obg7OIzwzl9BL8EO8
6 changed files with 109 additions and 102 deletions

View file

@ -23,10 +23,8 @@ impl IndexedQueue {
#[pyo3(signature = (items=None))]
fn new(items: Option<Py<PyAny>>) -> PyResult<Self> {
if let Some(py_object) = items {
Python::with_gil(|py| Self::from_any(py_object.bind(py))).and_then(|vec| {
Ok(Self {
backing: Box::new(IndexedBinaryHeap::from_iter(vec)),
})
Python::with_gil(|py| Self::from_any(py_object.bind(py))).map(|vec| Self {
backing: Box::new(IndexedBinaryHeap::from_iter(vec)),
})
} else {
Ok(Self {
@ -88,20 +86,18 @@ impl<'py> IndexedQueue {
fn from_any(object: &Bound<'py, PyAny>) -> PyResult<Vec<(PyItem, f64)>> {
if let Ok(vec) = object.extract::<Vec<(Py<PyAny>, f64)>>() {
Ok(Self::from_vec(vec))
} else {
if object.is_instance_of::<PyDict>() {
if let Ok(dict) = object.downcast::<PyDict>() {
Self::from_dict(dict)
} else {
Err(PyErr::new::<PyTypeError, _>(
"Argument claimed to be a dict but wasn't",
))
}
} else if object.is_instance_of::<PyDict>() {
if let Ok(dict) = object.downcast::<PyDict>() {
Self::from_dict(dict)
} else {
Err(PyErr::new::<PyTypeError, _>(
"Argument was not a properly-formed dict, list, or tuple",
"Argument claimed to be a dict but wasn't",
))
}
} else {
Err(PyErr::new::<PyTypeError, _>(
"Argument was not a properly-formed dict, list, or tuple",
))
}
}