While developing a new server extension using the server extension cookiecutter, I noticed that flake8 was failing in the pipeline but not locally. Looking more closely, it was because the flake8 precommit step was isolated into a "manual" hook stage, which, confusingly, doesn't actually run when you manually invoke pre-commit run --all-files.
Then, when I correctly specified the manual hook stage via pre-commit run --all-files --hook-stage=manual, the errors were not being automatically fixed! I had to go file by file, line by line, and correct them myself.
This got me thinking: why use flake8 in precommit at all? We already use black as a linter. There doesn't seem to be any particular value in having two linters running in tandem. Using both in tandem creates weird incompatibilities that force the presence of additional configuration to mitigate them (see .flake8 file in jupyter-server repo). Furthermore, issues and responses from the lead maintainer (https://github.com/PyCQA/flake8/issues/234) have me a bit concerned about the sustainability of flake8.
To fix this, ideally we would:
remove flake8 from server extension cookiecutter
remove flake8 from existing server extensions, e.g. jupyter-events, jupyter-server-fileid
(stretch goal, up for debate) remove flake8 from Jupyter Server without causing a massive diff that breaks all PRs
Black is a formatter, not a linter. Most linters, pylint included, cannot just fix the lint they find. While I agree the .flake8 file is annoying, flake8 is providing us value.
cc @blink1073
While developing a new server extension using the server extension cookiecutter, I noticed that flake8 was failing in the pipeline but not locally. Looking more closely, it was because the flake8 precommit step was isolated into a "manual" hook stage, which, confusingly, doesn't actually run when you manually invoke
pre-commit run --all-files
.Then, when I correctly specified the manual hook stage via
pre-commit run --all-files --hook-stage=manual
, the errors were not being automatically fixed! I had to go file by file, line by line, and correct them myself.This got me thinking: why use flake8 in precommit at all? We already use black as a linter. There doesn't seem to be any particular value in having two linters running in tandem. Using both in tandem creates weird incompatibilities that force the presence of additional configuration to mitigate them (see
.flake8
file injupyter-server
repo). Furthermore, issues and responses from the lead maintainer (https://github.com/PyCQA/flake8/issues/234) have me a bit concerned about the sustainability of flake8.To fix this, ideally we would:
flake8
from server extension cookiecutterflake8
from existing server extensions, e.g.jupyter-events
,jupyter-server-fileid
flake8
from Jupyter Server without causing a massive diff that breaks all PRs