Skip to content

[flake8-bugbear] Add B912: map() without an explicit strict= parameter#20429

Merged
dylwil3 merged 7 commits intoastral-sh:mainfrom
danparizher:rule/b912
Sep 19, 2025
Merged

[flake8-bugbear] Add B912: map() without an explicit strict= parameter#20429
dylwil3 merged 7 commits intoastral-sh:mainfrom
danparizher:rule/b912

Conversation

@danparizher
Copy link
Copy Markdown
Contributor

Summary

Implements new rule B912 that requires the strict= argument for map(...) calls with two or more iterables on Python 3.14+, following the same pattern as B905 for zip().

Closes #20057

@danparizher danparizher marked this pull request as ready for review September 16, 2025 04:44
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 16, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser MichaReiser added the rule Implementing or modifying a lint rule label Sep 16, 2025
Copy link
Copy Markdown
Collaborator

@dylwil3 dylwil3 left a comment

Choose a reason for hiding this comment

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

Thanks! This looks good - I wonder if we could reduce some code duplication

Comment thread crates/ruff_linter/src/rules/flake8_bugbear/rules/map_without_explicit_strict.rs Outdated
@danparizher
Copy link
Copy Markdown
Contributor Author

danparizher commented Sep 16, 2025

I extracted common helpers into strict_utils.rs:

  • is_infinite_iterable(...)
  • any_infinite_iterables(...)

Applied across B905, B911, and B912 to remove duplicated logic

Let me know if that makes the most sense, happy to adjust naming/placement of the helpers if you prefer a different structure

@danparizher danparizher requested a review from dylwil3 September 16, 2025 18:20
Copy link
Copy Markdown
Collaborator

@dylwil3 dylwil3 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!

@dylwil3 dylwil3 merged commit c94ddb5 into astral-sh:main Sep 19, 2025
36 checks passed
@dylwil3 dylwil3 added the preview Related to preview mode features label Sep 19, 2025
@danparizher danparizher deleted the rule/b912 branch September 19, 2025 18:01
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.

New rule: B912 require strict= argument for map(...) with >=2 iterables on Python 3.14+

3 participants