edgedb-python icon indicating copy to clipboard operation
edgedb-python copied to clipboard

Add a basic pre-commit lint and autoformat

Open adehad opened this issue 2 years ago • 13 comments

Following up on: https://github.com/edgedb/edgedb-python/issues/438

Summary of changes

  1. a pre-commit config file has been added with some simple rules
  2. 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

adehad avatar Jul 01 '23 22:07 adehad

All commit authors signed the Contributor License Agreement.
CLA signed

gel-data-cla[bot] avatar Jul 01 '23 22:07 gel-data-cla[bot]

@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

adehad avatar Jul 01 '23 22:07 adehad

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

chrisemke avatar Jul 08 '23 21:07 chrisemke

@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)

adehad avatar Jul 11 '23 13:07 adehad

Sorry, I didn't mean to close this PR.

fantix avatar Sep 14 '23 21:09 fantix

@fantix do let me know if you would like me to target the main branch instead of this drop-py37 branch

adehad avatar Sep 18 '23 11:09 adehad

Yes, please! Let's retarget and rebase to the master branch, and get this merged 🙏

fantix avatar Sep 18 '23 14:09 fantix

@fantix should be ready for review again now

adehad avatar Sep 18 '23 16:09 adehad

Didn't realise there were merge conflicts, should now be resolved and ready for review @fantix

adehad avatar Sep 29 '23 11:09 adehad

(bump) @fantix

adehad avatar Oct 05 '23 11:10 adehad

@fantix have just rebased now

adehad avatar Jan 15 '24 22:01 adehad

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.

fantix avatar Jan 15 '24 22:01 fantix

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

adehad avatar Jan 15 '24 22:01 adehad