mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 22:54:42 +00:00
[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:
parent
93413d3631
commit
37ba185c04
1 changed files with 24 additions and 4 deletions
|
@ -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],
|
||||||
/// ):
|
/// ):
|
||||||
/// ...
|
/// ...
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue