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

Remove part of FURB131: #239

Merged
merged 1 commit into from
Mar 20, 2023
Merged

Remove part of FURB131: #239

merged 1 commit into from
Mar 20, 2023

Conversation

dosisod
Copy link
Owner

@dosisod dosisod commented Mar 20, 2023

This PR removes a portion of FURB131 which suggested replacing most instances of del with .pop(). The reasoning behid it was not well founded, and in most cases, it is better to just leave the del statememt as it is. In one instance though, which is the del x[:] usage, it is more preferable to use the .clear() method, as it is faster and more readable.

Closes #234.

This PR removes a portion of FURB131 which suggested replacing most instances
of `del` with `.pop()`. The reasoning behid it was not well founded, and in
most cases, it is better to just leave the `del` statememt as it is. In one
instance though, which is the `del x[:]` usage, it is more preferable to use
the `.clear()` method, as it is faster and more readable.

Closes #234.
@dosisod dosisod merged commit 3f4b865 into master Mar 20, 2023
@dosisod dosisod deleted the update-furb131 branch March 20, 2023 04:43
dosisod added a commit that referenced this pull request Feb 1, 2024
FURB131 (previously `no-del`) has been broken for a while, basically since it's
initial creation. #239 fixed some of this, but introduced improper semantics by
implying you could use `del x[:]` when `x` is a `dict`, which is not true. This
means that FURB131 only really applies to `list` types now (or any sequence
that implements `.clear()`, though this isn't supported yet). I recently came
across a similar idiom for clearing an array, `x[:] = []`, which is about twice
as slow as `x.clear()`, and similar in nature to `del x[:]`. This new update
was what prompted me to fix all the broken logic.

With that in mind, this check has been renamed to `use-clear` since it no
longer is about the `del` statement, but about using slices to clear a list.
This shouldn't cause any issues since the name of checks are only used for
display purposes. This will break any hyperlinks to FURB131 in the docs, though
you'll still end up on the same page so I'm not too concerned about that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Question]: Why is FURB131 good in this case?
1 participant