Skip to content

inconsistent-mro: add autofix that moves Generic[] to the end of the bases list, if doing so would fix the violation #2309

@AlexWaygood

Description

@AlexWaygood

The first of these causes ty to issue an inconsistent-mro violation; the second one does not:

from typing import Generic, TypeVar

K = TypeVar("K")
V = TypeVar("V")

class Foo(Generic[K, V], dict): ...
class Bar(dict, Generic[K, V]): ...

And issues involving Generic[] are probably some of the most common causes of inconsistent-mro violations in user code. We should offer an autofix that moves the Generic[] element to the end of the bases list, if doing so would fix the inconsistent-mro violation.

Metadata

Metadata

Assignees

Labels

fixeshelp wantedContributions especially welcome

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions