From 37ba185c0419f706bd43e4de2f56f2fa7d1b74f3 Mon Sep 17 00:00:00 2001 From: GiGaGon <107241144+MeGaGiGaGon@users.noreply.github.com> Date: Wed, 2 Jul 2025 08:49:54 -0700 Subject: [PATCH] [`flake8-pyi`] Make example error out-of-the-box (`PYI059`) (#19080) Co-authored-by: Alex Waygood --- .../rules/generic_not_last_base_class.rs | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/generic_not_last_base_class.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/generic_not_last_base_class.rs index 7a94219cdc..19565abd56 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/generic_not_last_base_class.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/generic_not_last_base_class.rs @@ -21,27 +21,47 @@ use crate::{Fix, FixAvailability, Violation}; /// /// For example: /// ```python +/// from collections.abc import Container, Iterable, Sized +/// from typing import Generic, TypeVar +/// +/// +/// T = TypeVar("T") +/// K = TypeVar("K") +/// V = TypeVar("V") +/// +/// /// class LinkedList(Generic[T], Sized): /// def push(self, item: T) -> None: /// self._items.append(item) /// +/// /// class MyMapping( /// Generic[K, V], -/// Iterable[Tuple[K, V]], -/// Container[Tuple[K, V]], +/// Iterable[tuple[K, V]], +/// Container[tuple[K, V]], /// ): /// ... /// ``` /// /// Use instead: /// ```python +/// from collections.abc import Container, Iterable, Sized +/// from typing import Generic, TypeVar +/// +/// +/// T = TypeVar("T") +/// K = TypeVar("K") +/// V = TypeVar("V") +/// +/// /// class LinkedList(Sized, Generic[T]): /// def push(self, item: T) -> None: /// self._items.append(item) /// +/// /// class MyMapping( -/// Iterable[Tuple[K, V]], -/// Container[Tuple[K, V]], +/// Iterable[tuple[K, V]], +/// Container[tuple[K, V]], /// Generic[K, V], /// ): /// ...