-
Notifications
You must be signed in to change notification settings - Fork 82
Description
Currently, this project has 2 ways to run CQA tools:
tox -e style
pre-commit
To a new contributor, it might not be very clear how to run CQA tools.
Please don't take this the wrong way this is just my contributor experience it isn't meant as an attack.
I know first-hand that time for a FOSS maintainer is stretched VERY thin, sometimes you need to make hard calls like "tests pass, just linting fails so let's merge it, we will fix it later" and that typically no maintainer gets the praise that they deserve.
So thanks maintainers to not let a super nice project die and keeping it alive ❤️
My experience as a first-time contributor:
- I forked the repo and cloned my fork
- Installed the
pre-commit
git hooks (pre-commit install
) - And ran
pre-commit run -a
(as I usually do) to populate its cache with the tooling versions of this project - Suddenly there were a lot of changes in a clean clone
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .github/workflows/do-update-authors.yml
modified: CHANGELOG.md
modified: docs/source/authors.rst
modified: docs/source/license.rst
modified: src/docformatter/syntax.py
modified: src/docformatter/util.py
modified: tests/_data/string_files/do_format_code.toml
modified: tests/_data/string_files/do_format_docstrings.toml
modified: tests/_data/string_files/format_code.toml
modified: tests/formatter/test_do_format_docstring.py
modified: tests/test_configuration_functions.py
modified: tests/test_docformatter.py
modified: tests/test_encoding_functions.py
modified: tests/test_string_functions.py
modified: tests/test_syntax_functions.py
modified: tests/test_utility_functions.py
no changes added to commit (use "git add" and/or "git commit -a")
- So I git rest hard and uninstall the
pre-commit
git hooks (pre-commit uninstall
) - I do my changes and push to my fork to see that the
do-lint
workflow fails - I have to look up how CQA tools are run (also took a moment since I didn't see a
tox.ini
) and runtox -e style
locally tox -e style
also fails in a clean clone because of unpinned versions and tooling updates- Since
ruff
in.pre-commit-config.yaml
was very outdated I pinned it to that version in the tox env (that version of the hook used a sys executable since it didn't define a pyproject.toml to pin the version) this should "just fix it" right? - When I look at the sill failing CI I see that
pycodestyle
also has an error because linting on the default branch was broken since Aug 9, 2023 - Finally I can fix I wanted to fix
Advantages of running all CQA with pre-commit
:
- Single source of truth
- Reproducibility due to version locking (... mostly since sometimes something down in the dependency tree just breaks things 🙈)
- Easier maintenance due to update functionality (
pre-commit autoupdate
) - Clean commit history (no "Fix linting and formatting issues" commits)
Disadvantages of running all CQA with pre-commit
:
- Additional PRs/commits due to updating of pinned versions of tools BUT on your own schedule (same as pinning versions in the tox config)
Alternative:
Remove the .pre-commit-config.yaml
and use a tox.ini
, so experienced python project contributors know how to contribute even without a contributing guide (at least I did see a guide prominently mentioned)
I know given my PR it might seem like "Given this issue why do you advertise for pre-commit
?", but this is the first time that I experienced a problem that wouldn't have happened the same way with a fresh venv
or tox
.
While I have seen far more issues running tooling outside of pre-commit
(e.g. see above).
So if maintainers are ok with fully changing to pre-commit
as the CQA runner I would be happy to make a PR for this transition.