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

[ruff] Do not emit diagnostic when all arguments to zip() are variadic (RUF058) #15744

Merged
merged 2 commits into from
Jan 25, 2025

Conversation

InSyncWithFoo
Copy link
Contributor

Summary

Resolves #15742.

Previously, these would be considered violations:

# All arguments are variadic
starmap(print, zip(*a))
starmap(print, zip(*a, *b))

It is possible, however, that the user is relying on the fact that zip() can be called without arguments. On the other hand, map() can't be called with less than two arguments.

Thus, after this change, the aforementioned cases are no longer reported.

Test Plan

cargo nextest run and cargo insta test.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Yeah, good call -- they may be using the more verbose idiom precisely because it allows for variadic arguments where map() doesn't. So I think you're right; it doesn't make sense to emit the diagnostic here at all.

Thanks!

@AlexWaygood AlexWaygood added bug Something isn't working rule Implementing or modifying a lint rule labels Jan 25, 2025
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@AlexWaygood AlexWaygood added the preview Related to preview mode features label Jan 25, 2025
@AlexWaygood AlexWaygood merged commit cb3361e into astral-sh:main Jan 25, 2025
21 checks passed
@InSyncWithFoo InSyncWithFoo deleted the RUF058 branch January 25, 2025 18:46
dcreager added a commit that referenced this pull request Jan 27, 2025
* main:
  Run `cargo update` (#15769)
  [red-knot] Document public symbol type inferece (#15766)
  Update dawidd6/action-download-artifact action to v8 (#15760)
  Update NPM Development dependencies (#15758)
  Update pre-commit dependencies (#15756)
  Update dependency ruff to v0.9.3 (#15755)
  Update dependency mdformat-mkdocs to v4.1.2 (#15754)
  Update Rust crate uuid to v1.12.1 (#15753)
  Update Rust crate unicode-ident to v1.0.15 (#15752)
  Fix docstring in ruff_annotate_snippets (#15748)
  Update Rust crate insta to v1.42.1 (#15751)
  Update Rust crate clap to v4.5.27 (#15750)
  Add references to `trio.run_process` and `anyio.run_process` (#15761)
  [`ruff`] Do not emit diagnostic when all arguments to `zip()` are variadic (`RUF058`) (#15744)
  [red-knot] Ensure differently ordered unions are considered equivalent when they appear inside tuples inside top-level intersections (#15743)
  [red-knot] Ensure differently ordered unions and intersections are understood as equivalent even inside arbitrarily nested tuples (#15740)
  [red-knot] Promote the `all_type_pairs_are_assignable_to_their_union` property test to stable (#15739)
  [`pylint`] Do not trigger `PLR6201` on empty collections (#15732)
  Improve the file watching failure error message (#15728)
  Speed symbol state merging back up (#15731)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working preview Related to preview mode features rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RUF058 fix is broken when zip arguments are starred empty iterables
2 participants