Skip to content

B912: check if map calls have strict flag #517

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

Merged
merged 4 commits into from
Jun 23, 2025
Merged

Conversation

kasium
Copy link
Contributor

@kasium kasium commented Jun 23, 2025

Closes #516

@cooperlees cooperlees requested a review from Copilot June 23, 2025 13:49
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a new flake8-bugbear check (B912) to require an explicit strict= parameter on calls to map() when more than one iterable is provided.

  • Implements check_for_b912 in bugbear.py and registers the new error.
  • Adds tests in tests/eval_files/b912_py314.py to cover valid and invalid map() usages.
  • Updates README.rst with documentation and changelog entry for B912.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/eval_files/b912_py314.py New test cases for B912 rule; checks map calls.
bugbear.py Added check_for_b912 and registered B912 error.
README.rst Documented B912 and added changelog entry.
Comments suppressed due to low confidence (1)

tests/eval_files/b912_py314.py:2

  • The *map("c") expression is invalid since map() requires a function argument. If you intend to expand a single-character iterable, use *"c" or a list (e.g., *["c"]).
map(lambda x: x, "a", "b", *map("c"))  # B912: 0

kasium and others added 2 commits June 23, 2025 17:29
@cooperlees cooperlees merged commit ca05a35 into PyCQA:main Jun 23, 2025
6 checks passed
@kasium kasium deleted the issue-516 branch June 24, 2025 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New rule for strict flag on map
2 participants