Skip to content

Conversation

@fennr
Copy link

@fennr fennr commented May 29, 2025

close #513

I used B043 because I see PR with B042

@fennr
Copy link
Author

fennr commented May 29, 2025

@cooperlees check my PR please

@cooperlees cooperlees requested a review from Copilot September 8, 2025 19:54
Copy link
Contributor

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

This PR adds a new linting rule B043 that detects when delattr() is called with a constant string attribute name, suggesting to use direct attribute deletion instead.

  • Adds rule B043 to detect delattr(obj, "constant") usage patterns
  • Provides test cases demonstrating valid and invalid usage patterns
  • Updates documentation to explain the rule and its rationale

Reviewed Changes

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

File Description
tests/eval_files/b043.py Test cases showing valid dynamic usage vs invalid constant usage of delattr
bugbear.py Core logic to detect delattr calls with constant string arguments and error definition
README.rst Documentation explaining B043 rule and recommending del x.attr over delattr(x, 'attr')

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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 to check delattr with constant

1 participant