From 1602df164359e050f0f8fdbbaa60ae5ffb357be5 Mon Sep 17 00:00:00 2001 From: Aleksei Latyshev Date: Fri, 12 Jan 2024 14:48:45 +0100 Subject: [PATCH] Fix message for __aenter__ in PLC2801 (#9492) ## Summary Fix the message for `__aenter__ ` in PLC2801 (introduced in https://github.com/astral-sh/ruff/pull/9166) There is no `aenter` builtin in Python, so the current message is misleading. I take the message from original lint https://github.com/pylint-dev/pylint/blob/main/pylint/constants.py#L211 P.S. I think here should be more accurate synchronization with original lint (e.g. the current implementation will not lint `__enter__` on my first sight), but it is out-of-scope of this change. ## Test Plan --- .../src/rules/pylint/rules/unnecessary_dunder_call.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ruff_linter/src/rules/pylint/rules/unnecessary_dunder_call.rs b/crates/ruff_linter/src/rules/pylint/rules/unnecessary_dunder_call.rs index ea88f7b9121d0..2d8ebd9516691 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/unnecessary_dunder_call.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/unnecessary_dunder_call.rs @@ -273,7 +273,7 @@ impl DunderReplacement { "__str__" => Some(Self::Builtin("str", "Use `str()` builtin")), "__subclasscheck__" => Some(Self::Builtin("issubclass", "Use `issubclass()` builtin")), - "__aenter__" => Some(Self::MessageOnly("Use `aenter()` builtin")), + "__aenter__" => Some(Self::MessageOnly("Invoke context manager directly")), "__ceil__" => Some(Self::MessageOnly("Use `math.ceil()` function")), "__copy__" => Some(Self::MessageOnly("Use `copy.copy()` function")), "__deepcopy__" => Some(Self::MessageOnly("Use `copy.deepcopy()` function")),