From fbe4ff6607c6a1f4433a5af60d21365929c9c795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20S=C5=82awecki?= <bswck.dev@gmail.com> Date: Tue, 30 Jan 2024 16:10:45 +0100 Subject: [PATCH 1/2] Add `__mro_entries__` to known dunder methods Yes, I actually need this. --- crates/ruff_linter/src/rules/pylint/helpers.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/ruff_linter/src/rules/pylint/helpers.rs b/crates/ruff_linter/src/rules/pylint/helpers.rs index de867b31355e8..6c41fad31d3ce 100644 --- a/crates/ruff_linter/src/rules/pylint/helpers.rs +++ b/crates/ruff_linter/src/rules/pylint/helpers.rs @@ -280,6 +280,7 @@ pub(super) fn is_known_dunder_method(method: &str) -> bool { | "__missing__" | "__mod__" | "__module__" + | "__mro_entries__" | "__mul__" | "__ne__" | "__neg__" From 8893a3ca5784034101701bad8024e8bf59c6f8b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20S=C5=82awecki?= <bswck.dev@gmail.com> Date: Tue, 30 Jan 2024 16:24:19 +0100 Subject: [PATCH 2/2] Test `__mro_entries__` against known dunder methods --- .../resources/test/fixtures/pylint/bad_dunder_method_name.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/ruff_linter/resources/test/fixtures/pylint/bad_dunder_method_name.py b/crates/ruff_linter/resources/test/fixtures/pylint/bad_dunder_method_name.py index f8aaddbf96946..cf264981284c2 100644 --- a/crates/ruff_linter/resources/test/fixtures/pylint/bad_dunder_method_name.py +++ b/crates/ruff_linter/resources/test/fixtures/pylint/bad_dunder_method_name.py @@ -91,6 +91,9 @@ def __special_custom_magic__(self): def __prepare__(): pass + def __mro_entries__(self, bases): + pass + def __foo_bar__(): # this is not checked by the [bad-dunder-name] rule ...