Skip to content

Ruff as linter and formatter - #3756

Merged
alejoe91 merged 42 commits into
SpikeInterface:mainfrom
zm711:ruff-test
Nov 12, 2026
Merged

alejoe91 merged 42 commits into
SpikeInterface:mainfrom
zm711:ruff-test

Conversation

@zm711

@zm711 zm711 commented Mar 9, 2025

Copy link
Copy Markdown
Member

I just wanted to draft out so we could see. Right now if I did it right--though I doubt it haha. This should just check for unused imports... If we like this we could remove black auto commit and switch with a commit action in the future. But just want to see how this flows.

@zm711

zm711 commented Mar 9, 2025

Copy link
Copy Markdown
Member Author

That took ~3 seconds to run. That's insane! Just for unused imports right now. I think we would exclude init files so we could get fancier. But might be worth thinking about.

@zm711 zm711 added the continuous integration Related to CI label Mar 10, 2025
@zm711 zm711 mentioned this pull request Mar 12, 2025
@samuelgarcia

Copy link
Copy Markdown
Member

Mayeb it is time to switch no ?

@zm711

zm711 commented Sep 12, 2025

Copy link
Copy Markdown
Member Author

Well if we do switch we need to decide what we want. Currently this is set to lint imports only. But we can fine tune this. We could start by switching this to actually do the black formatting and then add rules if we need to get what we want. We can put this on a meeting agenda!

@zm711

zm711 commented Sep 19, 2025

Copy link
Copy Markdown
Member Author

@zm711 note to self. Turn this into a pre-commit action. Think about which rules we want to start with--probably just black-like formatting.

@alejoe91 alejoe91 added this to the 0.106.0 milestone Jul 17, 2026
@zm711

zm711 commented Nov 9, 2026

Copy link
Copy Markdown
Member Author

I think part of these failures are because some of our imports are hard for linters to check. I've made the same mistake where my IDE told me an important was unused only to remove it and push and see our tests fail here. So I think this will be a push-pull.

@alejoe91

Copy link
Copy Markdown
Member

Ok, I think I'm done with this. The default ruff config only run on src files and doesn't fix unused imports/variables:

# report but never auto-remove unused imports/variables: they may be side-effect imports, re-exports, or calls that advance state
unfixable = ['F401', 'F841']

I also added a manual pre-commit entry to run ruff on all files (which I did, and fix everything :) )

Added also a section in the docs on how to use it: https://spikeinterface--3756.org.readthedocs.build/en/3756/development/development.html#install-ruff-and-pre-commit

This is ready to merge (when all tests pass!) on my end

Comment thread doc/development/development.rst Resolved
@zm711
zm711 requested a review from chrishalcrow November 10, 2026 15:01
Comment thread doc/development/development.rst Resolved
Comment thread doc/development/development.rst Resolved
Comment thread doc/development/development.rst Resolved
Comment thread src/spikeinterface/core/loading.py Resolved
@chrishalcrow

Copy link
Copy Markdown
Member

Looks great, I scrolled through and stopped at anything that looked suspicious (not much). Would like approval from @samuelgarcia before merging! I'll also remind Sam that this PR is Zach's leaving gift!

@alejoe91

Copy link
Copy Markdown
Member

Looks great, I scrolled through and stopped at anything that looked suspicious (not much). Would like approval from @samuelgarcia before merging! I'll also remind Sam that this PR is Zach's leaving gift!

I vaguely remember Sam agreeing to switch to ruff. It's rust! So he likes it :) @samuelgarcia ?

@samuelgarcia

Copy link
Copy Markdown
Member

Alessio is doing a emotional blackmail on me to force me to approve this PR.
So I will do.

@alejoe91
alejoe91 merged commit 80a9f49 into SpikeInterface:main Nov 12, 2026
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

continuous integration Related to CI packaging Related to packaging/style

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants