$ ruff --version
ruff 0.5.6
$ cat ruf023.py
class Fraction:
__slots__ = "numerator", "denominator"
__match_args__ = __slots__
def __init__(self, numerator, denominator):
self.numerator = numerator
self.denominator = denominator
match Fraction(1, 2):
case Fraction(1, 2):
print("matched")
case _:
print("not matched")
$ python ruf023.py
matched
$ ruff check --isolated --preview --select RUF023 ruf023.py --fix
Found 1 error (1 fixed, 0 remaining).
$ python ruf023.py
not matched
The fix for RUF023 should be marked unsafe because the order of slots can be intentionally relied on, and changing it can change behavior. The fix is still safe if
__slots__is declared as a set.