Repository navigation
[flake8-bugbear] Document type-checker interaction (B010) - #28509
Conversation
| /// 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. | ||
| /// |
There was a problem hiding this comment.
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
setattrcall. 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.
There was a problem hiding this comment.
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.
flake8-bugbear] Document type-checker interaction (B010)
Pull request was closed
|
@ntBre Thank you so much |
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.