Fix and/or mute more clippy lints, deprecation warnings in Pyo3 (#2805)
This commit is contained in:
parent
7543a54d0d
commit
d39ded5b29
@ -357,6 +357,8 @@ mod tests {
|
||||
tree::{Tree, TreeLike},
|
||||
};
|
||||
|
||||
// Some (but not all) versions of clippy think the from_nt things are format strings.
|
||||
#[allow(clippy::literal_string_with_formatting_args)]
|
||||
#[test]
|
||||
fn simple_context() {
|
||||
let mut ctx = Context::new();
|
||||
|
@ -1,4 +1,6 @@
|
||||
use std::{string::String, vec::Vec};
|
||||
#![allow(clippy::useless_conversion)] // This seems to be a false-positive(?)
|
||||
|
||||
use std::{ffi::CString, string::String, vec::Vec};
|
||||
|
||||
use pyo3::{prelude::*, pyclass, types::IntoPyDict};
|
||||
|
||||
@ -48,8 +50,8 @@ impl PyContext {
|
||||
|
||||
fn loader(py: Python, grammar: &str) -> PyResult<Context> {
|
||||
let py_ctx = Bound::new(py, PyContext::new())?;
|
||||
let locals = [("ctx", &py_ctx)].into_py_dict_bound(py);
|
||||
py.run_bound(grammar, None, Some(&locals))?;
|
||||
let locals = [("ctx", &py_ctx)].into_py_dict(py)?;
|
||||
py.run(&CString::new(grammar)?, None, Some(&locals))?;
|
||||
Ok(py_ctx.borrow().get_context())
|
||||
}
|
||||
|
||||
|
@ -85,13 +85,13 @@ impl<'data, 'tree: 'data, 'ctx: 'data, W: Write, T: TreeLike> Unparser<'data, 't
|
||||
.into_iter()
|
||||
.map(io::Cursor::into_inner)
|
||||
.collect::<Vec<_>>();
|
||||
let byte_arrays = bufs.iter().map(|b| PyBytes::new_bound(py, b));
|
||||
let res = expr.call1(py, PyTuple::new_bound(py, byte_arrays))?;
|
||||
let byte_arrays = bufs.iter().map(|b| PyBytes::new(py, b));
|
||||
let res = expr.call1(py, PyTuple::new(py, byte_arrays)?)?;
|
||||
let bound = res.bind(py);
|
||||
if PyString::is_type_of_bound(bound) {
|
||||
if PyString::is_type_of(bound) {
|
||||
let pystr = bound.downcast::<PyString>()?;
|
||||
self.write(pystr.to_string_lossy().as_bytes());
|
||||
} else if PyBytes::is_type_of_bound(bound) {
|
||||
} else if PyBytes::is_type_of(bound) {
|
||||
let pybytes = bound.downcast::<PyBytes>()?;
|
||||
self.write(pybytes.as_bytes());
|
||||
} else {
|
||||
|
@ -286,7 +286,9 @@ pub mod pybind {
|
||||
a6: u64,
|
||||
a7: u64,
|
||||
) -> SyscallHookResult {
|
||||
unsafe { &*(&raw const PY_SYSCALL_HOOK).as_ref() }.map_or_else(
|
||||
// If we don't deref_addrof we run into the "static-mut-references" lint which is worse.
|
||||
#[expect(clippy::deref_addrof)]
|
||||
unsafe { (*(&raw const PY_SYSCALL_HOOK)).as_ref() }.map_or_else(
|
||||
|| SyscallHookResult::new(None),
|
||||
|obj| {
|
||||
let args = (sys_num, a0, a1, a2, a3, a4, a5, a6, a7);
|
||||
|
Loading…
x
Reference in New Issue
Block a user