-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NDSL] Add functionality to pre-commit #983
base: dsl/develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the codespell initiative. Not sure how well this will fly given all the cryptic abbreviations in the current code. It's probably a good thing though. Will force us to increase readability while we port. We probably want to have our own dictionary since the "--ignore-word-list" will be rather big.
If we gonna look at linting & formatting, we might want to look at the new ruff linter/formatter. According to the docs, it's a drop-in replacement for flake8, isort, and black. It comes with pre-commit integration and is orders of magnitudes faster than the traditional pipeline (its written in rust).
gt4py
is also using it and if we decide to move, it would be nicer to work in the NDSL (not here) repo because that pulls in gt4py as a submodule and currently I have to deactivate "format on save" option because vscode is will try to format it with the black formatter (apparently there's no way in vscode to have different formatters for the same language depending on folder structure). ruff
is mono-repo friendly and will use the closest ruff configuration allowing different config files per (submodule) folder.
Good point about codespell. We do want to make code more readable, but we have to be careful about doing that to early and losing people in the port. My heart is split on the subject. I think a more conservative approach would be to keep most variable names the same, change the function names, then go through the port with a few scientists for further explanation and refactor then? Maybe it's too complex of a strategy. As much as I'd like to burn |
ok, tested ruff. Works pretty well. Easy to handle config file. Is added now |
Additionally I created a codespell ignore file if we want to get rid of the appreviations we have in here. I still strongly believe that if we want to build a sustanable codebase our variables should not be named |
nice, with that you should be able to remove not only |
- repo: https://github.com/pre-commit/mirrors-isort | ||
rev: v5.4.2 | ||
hooks: | ||
- id: isort | ||
description: Group and sort Python imports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should also be able to get rid of isort
if we go with ruff
Purpose
Enhance featuers used in the pre-commit hook.
This PR adds two new hooks to run in pre-commit: codespell and pydocstyle. codespell checks for spelling errors and pydocstyle ensures conventions in documentation are upheld.
Code changes:
Add new hooks
.pre-commit-config.yaml
IMPORTANT
I did not change all the files to match these hooks yet. This works should be done once we've consolidated this list and would be a PR into this branch before merging to
dsl/develop