Skip to content

Commit

Permalink
Extend bad-dunder-method-name to permit attrs dunders (#7472)
Browse files Browse the repository at this point in the history
## Summary

Closes #7451.

## Test Plan

`cargo test`
  • Loading branch information
tjkuson committed Sep 17, 2023
1 parent 28273eb commit b66bfa6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ def __private_method(self):
def __doc__(self):
return "Docstring"

# Allow dunder methods recommended by attrs.
def __attrs_post_init__(self):
pass

def __attrs_pre_init__(self):
pass

def __attrs_init__(self):
pass


def __foo_bar__(): # this is not checked by the [bad-dunder-name] rule
...
3 changes: 3 additions & 0 deletions crates/ruff/src/rules/pylint/rules/bad_dunder_method_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ fn is_known_dunder_method(method: &str) -> bool {
| "__aiter__"
| "__and__"
| "__anext__"
| "__attrs_init__"
| "__attrs_post_init__"
| "__attrs_pre_init__"
| "__await__"
| "__bool__"
| "__bytes__"
Expand Down

0 comments on commit b66bfa6

Please sign in to comment.