You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently discovered Ruff, a replacement for Flake8 written in Rust (but available on PyPI), which is 10x–100x faster. Do you think we can/should use it in our CI?
Yes, I get almost 1000 errors, most of them (>99%) F401 (imported but unused). I tried passing the same config that we use, but I'm not sure if that worked (probably not, because we ignore __init__.py, where these F401 occur). I think it should be doable, but we should also investigate if Ruff supports all the checks that we currently use.
Currently, Ruff does not include PEP8 style checks, but these will be available very soon.
As a quick reminder to the person implementing the PR (probably me), we run Flake8 in codespell_and_flake.yml, and our Flake8 settings are in setup.cfg:
[flake8]
exclude = __init__.py,constants.py,fixes.py,resources.py,*doc/auto_*,*doc/_build*,build/*
ignore = W503,W504,I100,I101,I201,N806,E201,E202,E221,E222,E241
# We add A for the array-spacing plugin, and ignore the E ones it covers above
select = A,E,F,W,C
# 10_spectrum_class.py has a wide rST table
per-file-ignores =
tutorials/time-freq/10_spectrum_class.py:E501
[pydocstyle]
convention = pep257
match_dir = ^(?!\.|doc|tutorials|examples|logo|icons).*$
match = (?!tests/__init__\.py|fixes).*\.py
add-ignore = D100,D104,D107,D413
add-select = D214,D215,D404,D405,D406,D407,D408,D409,D410,D411
ignore-decorators = ^(copy_.*_doc_to_|on_trait_change|cached_property|deprecated|property|.*setter).*
This has to be translated to Ruff. Is it possible to get a list of rules that Flake8 checks with our config? We are only explicitly stating ignores, but I'd like to get a list of "not ignores".
Thanks for the crossrefs, I didn't know that you had already discussed this! I'm also a fan of precommit, and because we're already using black we don't even have to wait for Ruff to support style checks. Black, Ruff, and Codespell should be all we need, right?
I didn't know that you had already discussed this! I'm also a fan of precommit, and because we're already using black we don't even have to wait for Ruff to support style checks. Black, Ruff, and Codespell should be all we need, right?
Keep in mind those links are to mne-bids-pipeline where we have black+pre-commit IIRC. MNE-Python itself does not. We plan to go to black, but haven't done it yet: #10641
It would be good to use black for 1.4, maybe now is the time...
Activity
agramfort commentedon Mar 7, 2023
have you tried to run it locally on mne? does it lead to many different errors than flake8?
cbrnr commentedon Mar 7, 2023
Yes, I get almost 1000 errors, most of them (>99%) F401 (imported but unused). I tried passing the same config that we use, but I'm not sure if that worked (probably not, because we ignore
__init__.py, where these F401 occur). I think it should be doable, but we should also investigate if Ruff supports all the checks that we currently use.cbrnr commentedon Mar 7, 2023
I managed to provide our config, and now the errors are down to 7:
I still don't know how many rules that we use are not checked.
agramfort commentedon Mar 7, 2023
ok it seems it's a doable transition. Feel free to give it a try in a PR
cbrnr commentedon Mar 7, 2023
Currently, Ruff does not include PEP8 style checks, but these will be available very soon.
As a quick reminder to the person implementing the PR (probably me), we run Flake8 in
codespell_and_flake.yml, and our Flake8 settings are insetup.cfg:This has to be translated to Ruff. Is it possible to get a list of rules that Flake8 checks with our config? We are only explicitly stating ignores, but I'd like to get a list of "not ignores".
larsoner commentedon Mar 7, 2023
Don't know offhand, IIRC somewhere in the flake8 docs it say what the defaults are
drammock commentedon Mar 7, 2023
crossref to mne-tools/mne-bids-pipeline#686 and mne-tools/mne-bids-pipeline#688 in case it's helpful
drammock commentedon Mar 7, 2023
I'm especially keen on adding Ruff as a pre-commit hook, so that style errors (once they're supported) are caught before pushing to the remote
cbrnr commentedon Mar 8, 2023
Thanks for the crossrefs, I didn't know that you had already discussed this! I'm also a fan of precommit, and because we're already using black we don't even have to wait for Ruff to support style checks. Black, Ruff, and Codespell should be all we need, right?
cbrnr commentedon Mar 8, 2023
See #11541.
larsoner commentedon Mar 8, 2023
Keep in mind those links are to mne-bids-pipeline where we have black+pre-commit IIRC. MNE-Python itself does not. We plan to go to black, but haven't done it yet: #10641
It would be good to use black for 1.4, maybe now is the time...
cbrnr commentedon Mar 8, 2023
Yes, in #11541 only Codespell and Ruff are currently working, and I can only enable Black once someone has gone over the entire codebase.