HumanSignal/label-studio-sdk

[Suggestion] Autofix PRs with pre-commit.ci

lmmx opened this issue · 0 comments

lmmx commented

I was reading the PR below and saw that the merge had been prevented by linting:

Can you rerun the linter locally against your changes, it is failing the lint step.

This sounds like the exact use case pre-commit.ci was intended to solve: it does not require a GitHub Action workflow config, it just runs based on adding it to a repo:

Developers spend a fair chunk of time during their development flow on fixing relatively trivial problems in their code. pre-commit.ci both enforces that these issues are discovered (which is opt-in for each developer's workflow via pre-commit) but also fixes the issues automatically, letting developers focus their time on more valuable problems.

In other words, it removes the requirement for someone (be it someone sending a PR or someone reviewing it) to run the linter. The pre-commit.ci bot will run it and if it doesn't pass, it'll add a commit onto the PR branch that fixes the linting (ensuring no PR is blocked by linting).

Your lint step runs black --check --skip-string-normalization ./label_studio_sdk (here).

This would need to be a .pre-commit-config.yaml at the base of the repo. Here's the example from black's docs:

repos:
  - repo: https://github.com/psf/black
    rev: 23.7.0
    hooks:
      - id: black
        # It is recommended to specify the latest version of Python
        # supported by your project here, or alternatively use
        # pre-commit's default_language_version, see
        # https://pre-commit.com/#top_level-default_language_version
        language_version: python3.11

If you do want to use it in a GitHub Actions workflow you can use the lite version (but it doesn't autoupdate hook versions and runs slower). By default pre-commit will autoupdate weekly on a Monday.

Feel free to reject if it doesn't suit your needs, just a suggestion that might make life easier for LabelStudio 😸