Skip to content
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

[Suggestion] Autofix PRs with pre-commit.ci #143

Open
lmmx opened this issue Aug 3, 2023 · 0 comments
Open

[Suggestion] Autofix PRs with pre-commit.ci #143

lmmx opened this issue Aug 3, 2023 · 0 comments

Comments

@lmmx
Copy link

lmmx commented Aug 3, 2023

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 😸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant