Skip to content

Comments

[ruff] itertools.starmap(..., zip(...)) (RUF058)#15483

Merged
MichaReiser merged 8 commits intoastral-sh:mainfrom
InSyncWithFoo:RUF058
Jan 16, 2025
Merged

[ruff] itertools.starmap(..., zip(...)) (RUF058)#15483
MichaReiser merged 8 commits intoastral-sh:mainfrom
InSyncWithFoo:RUF058

Conversation

@InSyncWithFoo
Copy link
Contributor

@InSyncWithFoo InSyncWithFoo commented Jan 15, 2025

Summary

Resolves #15481, resolves #14835.

Test Plan

cargo nextest run and cargo insta test.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 15, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

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

pandas-dev/pandas (+1 -0 violations, +0 -0 fixes)

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

+ pandas/tests/arithmetic/test_datetime64.py:2214:32: RUF058 [*] `itertools.starmap` called on `zip` iterable

astropy/astropy (+1 -0 violations, +0 -0 fixes)

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

+ astropy/table/soco.py:81:34: RUF058 [*] `itertools.starmap` called on `zip` iterable

Changes by rule (1 rules affected)

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

Formatter (stable)

ℹ️ ecosystem check encountered format errors. (no format changes; 1 project error)

openai/openai-cookbook (error)

warning: Detected debug build without --no-cache.
error: Failed to read examples/Assistants_API_overview_python.ipynb: Expected a Jupyter Notebook, which must be internally stored as JSON, but this file isn't valid JSON: expected `,` or `]` at line 197 column 8

Formatter (preview)

ℹ️ ecosystem check encountered format errors. (no format changes; 1 project error)

openai/openai-cookbook (error)

ruff format --preview

warning: Detected debug build without --no-cache.
error: Failed to read examples/Assistants_API_overview_python.ipynb: Expected a Jupyter Notebook, which must be internally stored as JSON, but this file isn't valid JSON: expected `,` or `]` at line 197 column 8

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.

Thank you. I don't think we can implement this right now without changing FURB140. You can see in this playground that FURB140 recommends using starmap for map(..., zip). I think this is what I meant that we have to change FURB140 first but I incorrectly wrote map instead of saying that it shouldn't apply to zip.

@MichaReiser
Copy link
Member

MichaReiser commented Jan 15, 2025

I'll close this PR for now so that we can have the discussion in a single place. We can re-open it once we decide that the rule should be added and FURB140 is changed.

@MichaReiser MichaReiser reopened this Jan 15, 2025
@MichaReiser MichaReiser added rule Implementing or modifying a lint rule preview Related to preview mode features labels Jan 15, 2025
@InSyncWithFoo InSyncWithFoo mentioned this pull request Jan 15, 2025
1 task
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.

I pushed a commit that simplifies the fix a bit. I'm mainly trying to avoid using the tokens where they aren't strictly necessary because they add a fair bit of complexity and it's very easy to get them wrong.

@MichaReiser MichaReiser force-pushed the RUF058 branch 2 times, most recently from 012b7ba to 8c81ddf Compare January 16, 2025 11:47
@InSyncWithFoo
Copy link
Contributor Author

The changes are nice, especially the extra Arguments methods. Why isn't CI passing, though? I can't reproduce this locally.

@MichaReiser
Copy link
Member

I think it requires a rebase (github rebases your changes on main before running the checks)

@InSyncWithFoo InSyncWithFoo force-pushed the RUF058 branch 3 times, most recently from 5656447 to 7898991 Compare January 16, 2025 13:48
@MichaReiser MichaReiser merged commit aed0bf1 into astral-sh:main Jan 16, 2025
21 checks passed
@InSyncWithFoo InSyncWithFoo deleted the RUF058 branch January 16, 2025 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

itertools.starmap(func, zip(...)) FURB140 (reimplemented-starmap) suggests itertools.starmap when one should actually use map

2 participants