ruff/crates/ruff_linter
Dylan 4caeeb8d98
[pylint] Include name of base class in message for redefined-slots-in-subclass (W0244) (#15559)
In the following situation:

```python
class Grandparent:
  __slots__ = "a"

class Parent(Grandparent): ...

class Child(Parent):
  __slots__ = "a"
```

the message for `W0244` now specifies that `a` is overwriting a slot
from `Grandparent`.

To implement this, we introduce a helper function `iter_super_classes`
which does a breadth-first traversal of the superclasses of a given
class (as long as they are defined in the same file, due to the usual
limitations of the semantic model).

Note: Python does not allow conflicting slots definitions under multiple
inheritance. Unless I'm misunderstanding something, I believe It follows
that the subposet of superclasses of a given class that redefine a given
slot is in fact totally ordered. There is therefore a unique _nearest_
superclass whose slot is being overwritten. So, you know, in case anyone
was super worried about that... you can just chill.

This is a followup to #9640 .
2025-01-18 09:50:27 -06:00
..
resources [flake8-comprehensions] strip parentheses around generators in unnecessary-generator-set (C401) (#15553) 2025-01-17 18:08:22 +01:00
src [pylint] Include name of base class in message for redefined-slots-in-subclass (W0244) (#15559) 2025-01-18 09:50:27 -06:00
Cargo.toml Bump version to 0.9.2 (#15529) 2025-01-16 13:07:26 +00:00