Skip to content

[ruff] Add rule forbidding map(int, package.__version__.split('.')) (RUF048)#14373

Merged
AlexWaygood merged 8 commits intoastral-sh:mainfrom
InSyncWithFoo:RUF048
Nov 18, 2024
Merged

[ruff] Add rule forbidding map(int, package.__version__.split('.')) (RUF048)#14373
AlexWaygood merged 8 commits intoastral-sh:mainfrom
InSyncWithFoo:RUF048

Conversation

@InSyncWithFoo
Copy link
Copy Markdown
Contributor

Summary

Resolves #12961.

Test Plan

cargo nextest run and cargo insta test.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 16, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Copy Markdown
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.

Thanks!

I wonder if the rule should also flag [int(x) for x in __version__] and (int(x) for x in __version__)? But that could always be done as a followup.

Comment thread crates/ruff_linter/src/rules/ruff/rules/tuple_map_int_version_parsing.rs Outdated
Comment thread crates/ruff_linter/src/rules/ruff/rules/tuple_map_int_version_parsing.rs Outdated
Comment thread crates/ruff_linter/src/rules/ruff/rules/tuple_map_int_version_parsing.rs Outdated
Comment thread crates/ruff_linter/src/rules/ruff/rules/tuple_map_int_version_parsing.rs Outdated
Comment thread crates/ruff_linter/src/rules/ruff/rules/tuple_map_int_version_parsing.rs Outdated
Comment thread crates/ruff_linter/src/rules/ruff/rules/tuple_map_int_version_parsing.rs Outdated
Comment thread crates/ruff_linter/src/rules/ruff/rules/tuple_map_int_version_parsing.rs Outdated
@InSyncWithFoo
Copy link
Copy Markdown
Contributor Author

@AlexWaygood Thanks! All fixed.

@dhruvmanila dhruvmanila added rule Implementing or modifying a lint rule preview Related to preview mode features labels Nov 18, 2024
Copy link
Copy Markdown
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.

Thanks!

@AlexWaygood AlexWaygood changed the title [ruff] tuple(map(int, package.__version__.split('.'))) (RUF048) [ruff] Add rule forbidding map(int, package.__version__.split('.')) (RUF048) Nov 18, 2024
@AlexWaygood AlexWaygood enabled auto-merge (squash) November 18, 2024 13:40
@AlexWaygood AlexWaygood merged commit 3642381 into astral-sh:main Nov 18, 2024
@InSyncWithFoo InSyncWithFoo deleted the RUF048 branch November 20, 2024 03:46
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.

Idea: Test for bad version parsing tuple(map(int, __version__)))

3 participants