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 - false positive #1517

Closed
Czaki opened this issue Dec 31, 2022 · 1 comment · Fixed by #1520
Closed

RET504 - false positive #1517

Czaki opened this issue Dec 31, 2022 · 1 comment · Fixed by #1520
Labels
bug Something isn't working

Comments

@Czaki
Copy link
Contributor

Czaki commented Dec 31, 2022

I have checked that same problem also occurs in flake8-return so it is not a bug in logic translation, but definitely there is a problem with this rule. I also see #1035 with similar problems related to this plugin/set of rules.

The following code is reported as breaking RET504.

    def get_changes(self):
        ret = self.changes
        self.changes = []
        return ret

On one side, it fits in the description, on the other side, I do not see any better way to write such code.
Similarly to #1035 I do not use flake8-return earlier but would like to try these rules when seeing the description in the ruff readme.

@charliermarsh
Copy link
Member

That makes sense. We could cause assignments to invalidate the rule. I think we already do that for function calls.

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