Skip to content

[flake8-bugbear] Avoid false positives for calls with keyword arguments (B009, B010, B043) - #28776

Merged
ntBre merged 2 commits into
astral-sh:mainfrom
qinpei-dev:fix/b009-keyword-args
Sep 23, 2026
Merged

ntBre merged 2 commits into
astral-sh:mainfrom
qinpei-dev:fix/b009-keyword-args

Conversation

@qinpei-dev

Copy link
Copy Markdown
Contributor

B009 rewrote getattr calls containing keyword arguments or **kwargs, which could discard evaluation and side effects or change exceptions.

This prevents the rewrite from being offered for those calls and adds regression coverage.

Closes #28732

@astral-sh-bot
astral-sh-bot Bot requested a review from ntBre September 22, 2026 08:28
@ntBre ntBre added the bug An issue describing something that isn't working, or a PR that fixes a bug label Sep 22, 2026
@ntBre ntBre changed the title [B009] avoid fix when getattr has keyword arguments [flake8-bugbear] Avoid false positive when getattr has keyword arguments (B009) Sep 22, 2026

@ntBre ntBre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! This looks good to me for B009, but the related setattr and delattr rules could use the same treatment while we're here.

Comment thread crates/ruff_linter/src/checkers/ast/analyze/expression.rs Outdated
@astral-sh-bot

astral-sh-bot Bot commented Sep 22, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre ntBre changed the title [flake8-bugbear] Avoid false positive when getattr has keyword arguments (B009) [flake8-bugbear] Avoid false positives for calls with keyword arguments (B009, B010, B043) Sep 23, 2026

@ntBre ntBre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

@ntBre
ntBre merged commit bb76340 into astral-sh:main Sep 23, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An issue describing something that isn't working, or a PR that fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

B009 safe fix discards evaluation of ** arguments

2 participants