From 83a1e9bb8aaf1781bd001fa58c304776448a06bb Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Mon, 18 Sep 2023 17:02:24 +0200 Subject: [PATCH] Extend `bad-dunder-method-name` to permit `__html__` --- .../resources/test/fixtures/pylint/bad_dunder_method_name.py | 4 ++++ crates/ruff/src/rules/pylint/rules/bad_dunder_method_name.rs | 1 + 2 files changed, 5 insertions(+) diff --git a/crates/ruff/resources/test/fixtures/pylint/bad_dunder_method_name.py b/crates/ruff/resources/test/fixtures/pylint/bad_dunder_method_name.py index f03567ab1d162..be1cf65702e81 100644 --- a/crates/ruff/resources/test/fixtures/pylint/bad_dunder_method_name.py +++ b/crates/ruff/resources/test/fixtures/pylint/bad_dunder_method_name.py @@ -59,6 +59,10 @@ def __attrs_pre_init__(self): def __attrs_init__(self): pass + # Allow __html__, used by Jinja2 and Django. + def __html__(self): + pass + def __foo_bar__(): # this is not checked by the [bad-dunder-name] rule ... diff --git a/crates/ruff/src/rules/pylint/rules/bad_dunder_method_name.rs b/crates/ruff/src/rules/pylint/rules/bad_dunder_method_name.rs index b12a77db2397a..a3c3145798006 100644 --- a/crates/ruff/src/rules/pylint/rules/bad_dunder_method_name.rs +++ b/crates/ruff/src/rules/pylint/rules/bad_dunder_method_name.rs @@ -123,6 +123,7 @@ fn is_known_dunder_method(method: &str) -> bool { | "__getstate__" | "__gt__" | "__hash__" + | "__html__" | "__iadd__" | "__iand__" | "__ifloordiv__"