ion
ion copied to clipboard
Add `pre-commit` and use ruff
A similar change has been merged into Tin, see https://github.com/tjcsl/tin/pull/21
If you are reviewing this PR, I suggest looking at it commit-by-commit instead of looking at the diff all at once.
Proposed changes
- Use
pre-commit
for linting/formatting - Ideally maintainers will add
pre-commit ci
so that if the pre-commit fails, fixes will be pushed without having to run scripts.- Otherwise when creating a virtual environment, you can run
pre-commit install
and it should run pre-commit locally whenever you commit
- Otherwise when creating a virtual environment, you can run
- Change from
black
+autopep8
toruff
- Faster:
- Drop in replacement for
black
: https://docs.astral.sh/ruff/formatter/#black-compatibility - Flake8 plugins included
- Configurable in
pyproject.toml
- Faster:
Brief description of rationale
Running scripts is annoying lol
Summary of Changes
- Add
.pre-commit-config.yaml
- Also adds some config for
pre-commit ci
if it is decided to be added
- Also adds some config for
- Add
pre-commit
to dependencies - Changes test pipeline to run
pre-commit run --all-files
instead of scripts for formatting/linting - Deprecate the format scripts
Note
PR #1673 should be merged before this to see if all checks pass. I just tested locally, there are about ~11 files that are changed after merging it. Once it's merged I'll push a commit updating this PR with those 11 files.
Progress
- [X]
scripts/format.sh
- [X]
scripts/lint.sh
- [x]
scripts/build_sources.sh
- See #1669 ?
- [x]
scripts/static_templates_format.sh