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

[refurb] Make list-reverse-copy an unsafe fix #12303

Merged
merged 1 commit into from
Jul 13, 2024
Merged

Conversation

charliermarsh
Copy link
Member

Summary

I don't know that there's more to do here. We could consider not raising the violation at all for arguments, but that would have some false negatives and could also be surprising to users.

Closes #12267.

@charliermarsh charliermarsh added the fixes Related to suggested fixes for violations label Jul 12, 2024
@charliermarsh charliermarsh changed the title Make list-reverse-copy an unsafe fix [refurb] Make list-reverse-copy an unsafe fix Jul 12, 2024
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+0 -0 violations, +0 -2 fixes in 1 projects; 53 projects unchanged)

apache/airflow (+0 -0 violations, +0 -2 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

+ airflow/jobs/backfill_job_runner.py:943:13: FURB187 Use of assignment of `reversed` on list `dagrun_infos`
- airflow/jobs/backfill_job_runner.py:943:13: FURB187 [*] Use of assignment of `reversed` on list `dagrun_infos`

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
FURB187 2 0 0 0 2

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+0 -0 violations, +0 -2 fixes in 1 projects; 53 projects unchanged)

apache/airflow (+0 -0 violations, +0 -2 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ airflow/jobs/backfill_job_runner.py:943:13: FURB187 Use of assignment of `reversed` on list `dagrun_infos`
- airflow/jobs/backfill_job_runner.py:943:13: FURB187 [*] Use of assignment of `reversed` on list `dagrun_infos`

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
FURB187 2 0 0 0 2

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. Do we have other rules that apply fixes that mutate an object in place? These would also need to be marked as unsafe. It's not that we have to do this now. I'm mainly trying to understand the implication of marking such fixes as unsafe.

We might be able to get better at this long-term with Red Knot, if it has a way to reason whether a binding is local (not an argument), and has no aliases (CC: @carljm )

@charliermarsh
Copy link
Member Author

Yeah, it's possible that we could make this safe in some cases. Maybe if... there's only one binding, and there are no reads yet, and that binding is an assignment...?

@charliermarsh charliermarsh merged commit 6584886 into main Jul 13, 2024
20 checks passed
@charliermarsh charliermarsh deleted the charlie/furb187 branch July 13, 2024 19:45
@carljm
Copy link
Contributor

carljm commented Jul 14, 2024

Yes, it should be possible to find the cases where this is safe. They might turn out to not be very common in practice. I personally just don't like this lint rule at all, because in-place mutation is just fundamentally different, and that difference will be relevant in many practical cases. But making the autofix unsafe seems like a reasonable option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixes Related to suggested fixes for violations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FURB187 autofix can cause breaking changes
3 participants