Skip to content

Commit 0753968

Browse files
authored
add the "__prepare__" method to the list of recognized dunder method (#9529)
## Summary Closes #9508 . Add `__prepare__` method to dunder method list in `is_known_dunder_method`. ## Test Plan 1. add "__prepare__" method to `Apple` class in crates/ruff_linter/resources/test/fixtures/pylint/bad_dunder_method_name.py. 2. run `cargo test`
1 parent 66804ec commit 0753968

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

crates/ruff_linter/resources/test/fixtures/pylint/bad_dunder_method_name.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ def _(self):
8787
def __special_custom_magic__(self):
8888
pass
8989

90+
@classmethod
91+
def __prepare__():
92+
pass
93+
9094

9195
def __foo_bar__(): # this is not checked by the [bad-dunder-name] rule
9296
...

crates/ruff_linter/src/rules/pylint/helpers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ pub(super) fn is_known_dunder_method(method: &str) -> bool {
289289
| "__pos__"
290290
| "__post_init__"
291291
| "__pow__"
292+
| "__prepare__"
292293
| "__radd__"
293294
| "__rand__"
294295
| "__rdivmod__"

0 commit comments

Comments
 (0)