Replies: 1 comment 1 reply
|
Thanks for such a detailed account of your thoughts! I agree that the current solution is not that optimal, since the current pipelines don't really do anything and return a checkmark even if there are problems. I am very much a fan of making the entire process as effortless as possible for the developer with requiring the least dependencies as possible to setup for them. I am unsure whether using an additional dependency of ruff or pre-commit to be quite large commitments. Honestly, The optimal solution to me would be some sort of a github bot that applies all the auto-formatting to a pull request if a contributer were to type something like '!format'. I like this because the development of a feature doesn't need to care about reformatting and it allows for a simple solution to run when you think you are ready. This way all the checks would run again before we can push it onto dev. I am unsure of the maintainability of such a tool though (which may be an even larger problem). I would be happy to hear other thoughts on this too. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'd like to discuss about improving the current code checking process, maybe using
pre-commit, which can make the code check process easier.Current Status
Right now, several tools including
isort,black,docformatter,flake8, andpylintare required to run manually, as stated in CONTRIBUTING#Run code checks to keep our code style consistent.However these checks are NOT mandatory, and running these tools is not easy. so contributors can actually ignore these checks.
e.g. for EVERY FILE edited, one must run the following tools (and setting the correct filename to replace
myfile.py)There is also a GitHub workflow that runs these tools against ALL files, but it does not provide any errors, so most time people just ignore it.
e.g. : in this workflow run targeted at PR #1097:
blackhas reformatted 225 files:pylinthas several errors:However these re-formatted files are not commited back to the PR, and these errors do not block the merge. So after running all these checks, these problems still exists.
Proposed Solution
If we decide to enforce the code check, here are some choices:
Improve the current GitHub workflow
Which keeps everything the same, but in the workflow, commit all the modified files back to PR. So checks are run remotely but enforced.
2a. Or, switch to local
pre-commithooksWhich actually adds a fine-tuned
.pre-commit-config.yamlfile in the repo, which tellspre-committo do the exactlly same checks.Contributors can run
pre-commit runto check all the modified files with this yaml file. In addition, it can be executed automatically if one runspre-commit installlocally.It is best to re-format EVERY .py file with this hook in this step, too. So every commit after this will be focusing on the modified parts.
Documentary work is also needed with this step, to help collaborators correctly set up there hooks.
2b. Automated Checks on Pull Requests
After the first step, we can set up tools like pre-commit.ci to run the checks automatically on every PR, so it is enforced.
Switch to
rufffor faster checks (Note: May Change Formatting)As a future step, we might consider switching some of the code check tools to
ruff, which is much faster.However, switching to
ruffmight result in a large number of formatting changes across the codebase, which would require careful planning and coordination.Let's Discuss
I'd love to hear your thoughts on:
pre-committo make code checking process more visible to collaborators.ruff.I am able to provide a PR of
pre-commitif this makes sense.Looking forward to your input!
All reactions