---
source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs
---
PYI059 [*] `Generic[]` should always be the last base class
  --> PYI059.py:8:17
   |
 6 | V = TypeVar('V')
 7 |
 8 | class LinkedList(Generic[T], Sized):  # PYI059
   |                 ^^^^^^^^^^^^^^^^^^^
 9 |     def __init__(self) -> None:
10 |         self._items: List[T] = []
   |
help: Move `Generic[]` to the end
  |
7 |
  - class LinkedList(Generic[T], Sized):  # PYI059
8 + class LinkedList(Sized, Generic[T]):  # PYI059
9 |     def __init__(self) -> None:
  |
note: This is an unsafe fix and may change runtime behavior

PYI059 [*] `Generic[]` should always be the last base class
  --> PYI059.py:15:16
   |
13 |           self._items.append(item)
14 |
15 |   class MyMapping(  # PYI059
   |  ________________^
16 | |     t.Generic[K, V],
17 | |     Iterable[Tuple[K, V]],
18 | |     Container[Tuple[K, V]],
19 | | ):
   | |_^
20 |       ...
   |
help: Move `Generic[]` to the end
   |
15 | class MyMapping(  # PYI059
   -     t.Generic[K, V],
16 |     Iterable[Tuple[K, V]],
   -     Container[Tuple[K, V]],
17 +     Container[Tuple[K, V]], t.Generic[K, V],
18 | ):
   |
note: This is an unsafe fix and may change runtime behavior

PYI059 [*] `Generic[]` should always be the last base class
  --> PYI059.py:26:10
   |
24 | # to flag this issue in this case as well, since after fixing the error
25 | # the Generic's position issue persists.
26 | class Foo(Generic, LinkedList):  # PYI059
   |          ^^^^^^^^^^^^^^^^^^^^^
27 |     pass
   |
help: Move `Generic[]` to the end
   |
25 | # the Generic's position issue persists.
   - class Foo(Generic, LinkedList):  # PYI059
26 + class Foo(LinkedList, Generic):  # PYI059
27 |     pass
   |
note: This is an unsafe fix and may change runtime behavior

PYI059 [*] `Generic[]` should always be the last base class
  --> PYI059.py:30:10
   |
30 |   class Foo(  # comment about the bracket
   |  __________^
31 | |     # Part 1 of multiline comment 1
32 | |     # Part 2 of multiline comment 1
33 | |     Generic[T]  # comment about Generic[T]  # PYI059
34 | |     # another comment?
35 | |     ,  # comment about the comma?
36 | |     # part 1 of multiline comment 2
37 | |     # part 2 of multiline comment 2
38 | |     int,  # comment about int
39 | |     # yet another comment?
40 | | ):  # and another one for good measure
   | |_^
41 |       ...
   |
help: Move `Generic[]` to the end
   |
32 |     # Part 2 of multiline comment 1
   -     Generic[T]  # comment about Generic[T]  # PYI059
   -     # another comment?
   -     ,  # comment about the comma?
33 +     # comment about the comma?
34 |     # part 1 of multiline comment 2
35 |     # part 2 of multiline comment 2
   -     int,  # comment about int
36 +     int, Generic[T],  # comment about int
37 |     # yet another comment?
   |
note: This is an unsafe fix and may change runtime behavior

PYI059 `Generic[]` should always be the last base class
  --> PYI059.py:45:8
   |
44 | # in case of multiple Generic[] inheritance, don't fix it.
45 | class C(Generic[T], Generic[K, V]): ...  # PYI059
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: Move `Generic[]` to the end

PYI059 [*] `Generic[]` should always be the last base class
  --> PYI059.py:59:9
   |
57 | # syntax errors with starred and keyword arguments from
58 | # https://github.com/astral-sh/ruff/issues/18602
59 | class C1(Generic[T], str, **{"metaclass": type}):  # PYI059
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
60 |     ...
   |
help: Move `Generic[]` to the end
   |
58 | # https://github.com/astral-sh/ruff/issues/18602
   - class C1(Generic[T], str, **{"metaclass": type}):  # PYI059
59 + class C1(str, Generic[T], **{"metaclass": type}):  # PYI059
60 |     ...
   |
note: This is an unsafe fix and may change runtime behavior

PYI059 [*] `Generic[]` should always be the last base class
  --> PYI059.py:62:9
   |
60 |     ...
61 |
62 | class C2(Generic[T], str, metaclass=type):  # PYI059
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63 |     ...
   |
help: Move `Generic[]` to the end
   |
61 |
   - class C2(Generic[T], str, metaclass=type):  # PYI059
62 + class C2(str, Generic[T], metaclass=type):  # PYI059
63 |     ...
   |
note: This is an unsafe fix and may change runtime behavior

PYI059 `Generic[]` should always be the last base class
  --> PYI059.py:65:9
   |
63 |     ...
64 |
65 | class C3(Generic[T], metaclass=type, *[str]):  # PYI059 but no fix
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66 |     ...
   |
help: Move `Generic[]` to the end
