napari / napari

napari: a fast, interactive, multi-dimensional image viewer for python
https://napari.org
BSD 3-Clause "New" or "Revised" License
2.07k stars 410 forks source link

Enable ruff SLOT linting rule #6843

Closed brisvag closed 4 weeks ago

brisvag commented 1 month ago

References and relevant issues

Updating ruff linting rules is tracked by #5589.

Documentation for the SLOT linting rule can be found at: https://docs.astral.sh/ruff/rules/#flake8-slots-slot

Subclasses of str should define __slots__ Subclasses of tuple should define __slots__ Subclasses of {namedtuple_kind} should define __slots__

Description

The benefit of these rules is memory savings, because classes with __slots__ are more compact than classes with arbitrary attribute dictionaries. This is typically a small benefit, but could speed up some stuff like translations.

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 92.38%. Comparing base (dec8b09) to head (892fa7b).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #6843 +/- ## ========================================== - Coverage 92.44% 92.38% -0.06% ========================================== Files 614 614 Lines 54830 54833 +3 ========================================== - Hits 50686 50660 -26 - Misses 4144 4173 +29 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

jni commented 1 month ago

I've updated the title and description. In general, before merging and/or applying the ready-to-merge label, it would be good to have more thorough descriptions like the above. Many of these rules are mysterious even to long-time Python developers 🙋😅.