Skip to content

Comments

Minor followups to RUF052#14755

Merged
AlexWaygood merged 1 commit intomainfrom
alex/ruf052-nits
Dec 3, 2024
Merged

Minor followups to RUF052#14755
AlexWaygood merged 1 commit intomainfrom
alex/ruf052-nits

Conversation

@AlexWaygood
Copy link
Member

Summary

Just some minor followups to the recently merged RUF052 rule, that was added in bf0fd04:

  • Some small tweaks to the docs
  • A minor code-style nit
  • Some more tests for my peace of mind, just to check that the new methods on the semantic model are working correctly

I'm adding the "internal" label as this doesn't deserve a changelog entry. RUF052 is a new rule that hasn't been released yet.

Test Plan

cargo test -p ruff_linter

@AlexWaygood AlexWaygood added the internal An internal refactor or improvement label Dec 3, 2024
@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@AlexWaygood AlexWaygood merged commit 81bfcc9 into main Dec 3, 2024
@AlexWaygood AlexWaygood deleted the alex/ruf052-nits branch December 3, 2024 13:33
dcreager added a commit that referenced this pull request Dec 3, 2024
* main:
  [`ruff`] Extend unnecessary-regular-expression to non-literal strings (`RUF055`) (#14679)
  Minor followups to RUF052 (#14755)
  [red-knot] Property tests (#14178)
  [red-knot] `is_subtype_of` fix for `KnownInstance` types (#14750)
  Improve docs for flake8-use-pathlib rules (#14741)
  [`ruff`] Implemented `used-dummy-variable` (`RUF052`) (#14611)
  [red-knot] Simplify tuples containing `Never` (#14744)
  Possible fix for flaky file watching test (#14543)
  [`flake8-import-conventions`] Improve syntax check for aliases supplied in configuration for `unconventional-import-alias (ICN001)` (#14745)
  [red-knot] Deeper understanding of `LiteralString` (#14649)
  red-knot: support narrowing for bool(E) (#14668)
  [`refurb`] Handle non-finite decimals in `verbose-decimal-constructor (FURB157)` (#14596)
  [red-knot] Re-enable linter corpus tests (#14736)
@alessio-locatelli
Copy link

@AlexWaygood @MichaReiser Searching https://github.com/search?q=repo%3Aastral-sh%2Fruff+RUF052&type=issues does not reveal previous discussions on detecting used dummy variables inside FOR loops and list comprehensions. To avoid extra noise from rushing into opening a new issue, I would like to clarify: Was this rejected somewhere, or was this just not discussed and not implemented yet?

Example:

def no_ruff_warnings():
    my_list = [{"foo": 1}, {"foo": 2}]

    i = 0
    for _ in my_list:
        i += _["foo"]  # A dummy variable is used, but no warnings. 

    for _item in my_list:
        i += _item["foo"]  # A dummy variable is used, but no warnings. 

    [_["foo"] for _ in my_list]  # A dummy variable is used, but no warnings. 

    [_item["foo"] for _item in my_list]  # A dummy variable is used, but no warnings. 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants