Add a basic pre-commit lint and autoformat
Following up on: https://github.com/edgedb/edgedb-python/issues/438
Summary of changes
- a pre-commit config file has been added with some simple rules
- Errors picked up during the linting have been addressed and added as separate commits for clarity
NOTE
Target branch
~~This is targetting the drop-py37 branch. As it was assumed this PR would be merged after #435 .~~
Running the lint
The assumption is that pre-commit.ci GitHub integration is going to be setup for this project and therefore a dedicate lint GHA has NOT been setup, although it may look like:
---
name: Lint
on:
push:
branches:
- master
- ci
pull_request:
branches:
- master
workflow_dispatch:
inputs: {}
jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
submodules: true
- name: pre-commit
run: |
python -m pip install pre-commit
python -m pre_commit run --all-files
@fantix Might be an issue that tests aren't running on this PR yet (due to it not targetting the master branch).
Happy to wait for #435 to be merged first
Another thing that would be really cool would be an edgedb hook to (but not limited to) verifying or formatting the .esdl and .edgeql files
@fantix feel free commit any of the suggestions. (Personally I don't think the name addition to the pre-commit config adds much, I've mainly used it when I am running the same tool multiple times but with different configurations)
Sorry, I didn't mean to close this PR.
@fantix do let me know if you would like me to target the main branch instead of this drop-py37 branch
Yes, please! Let's retarget and rebase to the master branch, and get this merged 🙏
@fantix should be ready for review again now
Didn't realise there were merge conflicts, should now be resolved and ready for review @fantix
(bump) @fantix
@fantix have just rebased now
Thanks for the updates! I talked to the team and decided we don't want a pre-commit hook yet. However, I think the formatted code could stay (with a few nitpicking, for which I'll add comments on this PR) and we can probably have a test that runs the linter and formatter for checking.
and we can probably have a test that runs the linter and formatter for checking.
Yep, we do this too rather that as a pre-commit hook itself. I can recommend using the pre-commit.ci github action/app as this automates the process of checking PRs