mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-10 05:39:12 +00:00
![]()
Some checks failed
CI / Determine changes (push) Has been cancelled
CI / cargo fmt (push) Has been cancelled
CI / cargo build (release) (push) Has been cancelled
CI / mkdocs (push) Has been cancelled
CI / python package (push) Has been cancelled
CI / pre-commit (push) Has been cancelled
[ty Playground] Release / publish (push) Has been cancelled
CI / cargo clippy (push) Has been cancelled
CI / cargo test (linux) (push) Has been cancelled
CI / cargo test (linux, release) (push) Has been cancelled
CI / cargo test (windows) (push) Has been cancelled
CI / cargo test (wasm) (push) Has been cancelled
CI / cargo build (msrv) (push) Has been cancelled
CI / cargo fuzz build (push) Has been cancelled
CI / fuzz parser (push) Has been cancelled
CI / test scripts (push) Has been cancelled
CI / ecosystem (push) Has been cancelled
CI / Fuzz for new ty panics (push) Has been cancelled
CI / cargo shear (push) Has been cancelled
CI / formatter instabilities and black similarity (push) Has been cancelled
CI / test ruff-lsp (push) Has been cancelled
CI / check playground (push) Has been cancelled
CI / benchmarks (push) Has been cancelled
## Summary It doesn't seem to be necessary for our generics implementation to carry the `GenericContext` in the `ClassBase` variants. Removing it simplifies the code, fixes many TODOs about `Generic` or `Protocol` appearing multiple times in MROs when each should only appear at most once, and allows us to more accurately detect runtime errors that occur due to `Generic` or `Protocol` appearing multiple times in a class's bases. In order to remove the `GenericContext` from the `ClassBase` variant, it turns out to be necessary to emulate `typing._GenericAlias.__mro_entries__`, or we end up with a large number of false-positive `inconsistent-mro` errors. This PR therefore also does that. Lastly, this PR fixes the inferred MROs of PEP-695 generic classes, which implicitly inherit from `Generic` even if they have no explicit bases. ## Test Plan mdtests |
||
---|---|---|
.. | ||
annotations | ||
assignment | ||
binary | ||
boolean | ||
boundness_declaredness | ||
call | ||
class | ||
comparison | ||
comprehensions | ||
conditional | ||
declaration | ||
diagnostics | ||
directives | ||
doc | ||
exception | ||
expression | ||
function | ||
generics | ||
import | ||
literal | ||
loops | ||
narrow | ||
regression | ||
scopes | ||
shadowing | ||
snapshots | ||
stubs | ||
subscript | ||
suppressions | ||
type_of | ||
type_properties | ||
type_qualifiers | ||
unary | ||
with | ||
.mdformat.toml | ||
attributes.md | ||
cycle.md | ||
dataclass_transform.md | ||
dataclasses.md | ||
decorators.md | ||
descriptor_protocol.md | ||
final.md | ||
intersection_types.md | ||
invalid_syntax.md | ||
known_constants.md | ||
mdtest_config.md | ||
mdtest_custom_typeshed.md | ||
metaclass.md | ||
mro.md | ||
named_tuple.md | ||
overloads.md | ||
pep695_type_aliases.md | ||
properties.md | ||
protocols.md | ||
slots.md | ||
statically_known_branches.md | ||
sys_platform.md | ||
sys_version_info.md | ||
terminal_statements.md | ||
type_api.md | ||
typed_dict.md | ||
union_types.md | ||
unpacking.md | ||
unreachable.md |