Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"useless_conversion" with #[pyfunction] returning PyResult<_> on nightly #4828

Open
mgaertne opened this issue Dec 29, 2024 · 1 comment · May be fixed by #4838
Open

"useless_conversion" with #[pyfunction] returning PyResult<_> on nightly #4828

mgaertne opened this issue Dec 29, 2024 · 1 comment · May be fixed by #4838
Labels

Comments

@mgaertne
Copy link

mgaertne commented Dec 29, 2024

Bug Description

Clippy complains about a useless conversion to PyErr for functions returning PyResult<[anything]> on the latest nightly toolchain.

Steps to Reproduce

Example function:

#[pyfunction]
#[pyo3(name = "set_cvar_limit")]
#[pyo3(signature = (cvar, value, min, max, flags=None))]
pub(crate) fn pyshinqlx_set_cvar_limit(
    py: Python<'_>,
    cvar: &str,
    value: &str,
    min: &str,
    max: &str,
    flags: Option<i32>,
) -> PyResult<()> {
    py.allow_threads(|| {
        MAIN_ENGINE.load().as_ref().map_or(
            Err(PyEnvironmentError::new_err(
                "main quake live engine not set",
            )),
            |main_engine| {
                main_engine.set_cvar_limit(cvar, value, min, max, flags);

                Ok(())
            },
        )
    })
}

Backtrace

error: useless conversion to the same type: `pyo3::PyErr`
  --> src\ffi\python\embed\set_cvar_limit.rs:17:18
   |
17 | ) -> PyResult<()> {
   |                  ^
   |                  |
   |                  help: consider removing
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

Your operating system and version

Windows 11, Linux, MacOS

Your Python version (python --version)

3.11.9

Your Rust version (rustc --version)

1.85 nightly

Your PyO3 version

0.23.3

How did you install python? Did you use a virtualenv?

uv, venv

Additional Info

No response

@mgaertne mgaertne added the bug label Dec 29, 2024
@bionicles
Copy link

same issue

#[allow(clippy::useless_conversion)] on the function before the #[pyfunction] doesn't work

#![allow(clippy::useless_conversion)] on the whole module does silence the warnings

problem is, that makes it harder to find other useless conversions!

@mejrs mejrs linked a pull request Jan 6, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants