Skip to content

[flake8-bugbear] Document type-checker interaction (B010) - #28509

Merged
ntBre merged 2 commits into
astral-sh:mainfrom
GruffElixir:docs/28493-b010-method-fix
Sep 17, 2026
Merged

ntBre merged 2 commits into
astral-sh:mainfrom
GruffElixir:docs/28493-b010-method-fix

Conversation

@GruffElixir

Copy link
Copy Markdown
Contributor

Summary

Document that B010's assignment fix can be rejected by static type checkers when the target is typed as a method or otherwise does not allow assignment, even if the original setattr call is accepted. This records the limitation without changing runtime fix-safety classification.

Test Plan

Documentation-only change; no code tests are required.

Copilot AI lite review requested due to automatic review settings September 10, 2026 23:31
@astral-sh-bot
astral-sh-bot Bot requested a review from ntBre September 10, 2026 23:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment on lines +43 to +48
/// The fix does not account for static type-checker constraints. A type checker
/// may reject the resulting assignment when the target is typed as a method or
/// otherwise does not allow assignment, even if it accepts the original
/// `setattr` call. Review this fix against the type-checking configuration used
/// by the project.
///

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.

Hmm, this isn't exactly how I'd phrase it. As I tried to describe in my comment on the issue, the original code is actually bypassing the type checker's analysis, whereas this paragraph sounds to me like the rule is introducing a totally new problem.

I think I'd say something more like:

In some cases, a type checker may be able to analyze an assignment more thoroughly than a setattr call. Applying the fix in such cases may result in new type checking diagnostics, even if the runtime behavior of the code is unchanged.

Also, however we phrase it, this condition doesn't affect the fix's safety, so this probably belongs under a ## Known issues heading instead of here in the middle of the existing fix safety docs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep, good call. I reworded this to match the issue discussion and moved it under ## Known issues, since it does not affect the runtime safety of the fix. Pushed in 10f75de.

@ntBre ntBre changed the title Document B010 type-checker limitation [flake8-bugbear] Document type-checker interaction (B010) Sep 17, 2026
@ntBre ntBre added the documentation Improvements or additions to public-facing documentation label Sep 17, 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 enabled auto-merge (squash) September 17, 2026 14:15
@ntBre ntBre closed this Sep 17, 2026
auto-merge was automatically disabled September 17, 2026 14:20

Pull request was closed

@ntBre ntBre reopened this Sep 17, 2026
@astral-sh-bot
astral-sh-bot Bot requested a review from ntBre September 17, 2026 14:20
@ntBre
ntBre enabled auto-merge (squash) September 17, 2026 14:20
@ntBre
ntBre merged commit bd11fd1 into astral-sh:main Sep 17, 2026
93 of 98 checks passed
@GruffElixir

Copy link
Copy Markdown
Contributor Author

@ntBre Thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to public-facing documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[flake8-bugbear] B010's safe fix turns type-clean code into a type error when the attribute is a method

4 participants