[flake8-pyi] Make example error out-of-the-box (PYI059) (#19080)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
GiGaGon 2025-07-02 08:49:54 -07:00 committed by GitHub
parent 93413d3631
commit 37ba185c04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,27 +21,47 @@ use crate::{Fix, FixAvailability, Violation};
/// ///
/// For example: /// For example:
/// ```python /// ```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): /// class LinkedList(Generic[T], Sized):
/// def push(self, item: T) -> None: /// def push(self, item: T) -> None:
/// self._items.append(item) /// self._items.append(item)
/// ///
///
/// class MyMapping( /// class MyMapping(
/// Generic[K, V], /// Generic[K, V],
/// Iterable[Tuple[K, V]], /// Iterable[tuple[K, V]],
/// Container[Tuple[K, V]], /// Container[tuple[K, V]],
/// ): /// ):
/// ... /// ...
/// ``` /// ```
/// ///
/// Use instead: /// Use instead:
/// ```python /// ```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]): /// class LinkedList(Sized, Generic[T]):
/// def push(self, item: T) -> None: /// def push(self, item: T) -> None:
/// self._items.append(item) /// self._items.append(item)
/// ///
///
/// class MyMapping( /// class MyMapping(
/// Iterable[Tuple[K, V]], /// Iterable[tuple[K, V]],
/// Container[Tuple[K, V]], /// Container[tuple[K, V]],
/// Generic[K, V], /// Generic[K, V],
/// ): /// ):
/// ... /// ...