From cdf91b8b74703a5ecf9ee158506bf5a018266c66 Mon Sep 17 00:00:00 2001 From: GiGaGon <107241144+MeGaGiGaGon@users.noreply.github.com> Date: Wed, 2 Jul 2025 00:21:39 -0700 Subject: [PATCH] [`flake8-pyi`] Make example error out-of-the-box (`PYI062`) (#19079) ## Summary Part of #18972 This PR makes [duplicate-literal-member (PYI062)](https://docs.astral.sh/ruff/rules/duplicate-literal-member/#duplicate-literal-member-pyi062)'s example error out-of-the-box [Old example](https://play.ruff.rs/6b00b41c-c1c5-4421-873d-fc2a143e7337) ```py foo: Literal["a", "b", "a"] ``` [New example](https://play.ruff.rs/1aea839b-9ae8-4848-bb83-2637e1a68ce4) ```py from typing import Literal foo: Literal["a", "b", "a"] ``` Imports were also added to the "use instead" section. ## Test Plan N/A, no functionality/tests affected --- .../src/rules/flake8_pyi/rules/duplicate_literal_member.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_literal_member.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_literal_member.rs index 154a2bdc41..fea4985036 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_literal_member.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_literal_member.rs @@ -19,11 +19,15 @@ use crate::{AlwaysFixableViolation, Applicability, Edit, Fix}; /// /// ## Example /// ```python +/// from typing import Literal +/// /// foo: Literal["a", "b", "a"] /// ``` /// /// Use instead: /// ```python +/// from typing import Literal +/// /// foo: Literal["a", "b"] /// ``` ///