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

RET504 off-by-1 line / bogus error when returning an argument #3992

Closed
hynek opened this issue Apr 17, 2023 · 1 comment · Fixed by #4004
Closed

RET504 off-by-1 line / bogus error when returning an argument #3992

hynek opened this issue Apr 17, 2023 · 1 comment · Fixed by #4004
Assignees
Labels
bug Something isn't working

Comments

@hynek
Copy link

hynek commented Apr 17, 2023

Consider the following file t.py:

def str_to_bool(val):
    if isinstance(val, bool):
        return val
    val = val.strip().lower()
    if val in ("1", "true", "yes"):
        return True

    return False

Running pipx run ruff check --isolated --select RET504 t.py gives me:

t.py:3:16: RET504 Unnecessary variable assignment before `return` statement

So it points at the return val that hasn't assigned anything.

If I set val by hand instead of passing it in as an argument, there is no error.


$ pipx run ruff --version
ruff 0.0.261

no pyproject.toml

@charliermarsh charliermarsh added the bug Something isn't working label Apr 17, 2023
@charliermarsh
Copy link
Member

👍 Definitely a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants