HumanSignal / HumanSignal/label-studio-sdk

[Suggestion] Autofix PRs with pre-commit.ci

Open
#143 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
192
Forks
127
Avg merge
1d 18h
Merged PRs (30d)
1

Description

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.

- https://github.com/HumanSignal/label-studio-sdk/pull/142#issuecomment-1663107085

This sounds like the exact use case [pre-commit.ci](https://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](https://pre-commit.ci/) both enforces that these issues are discovered (which is opt-in for each developer's workflow via [pre-commit](https://pre-commit.com/)) 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](https://github.com/HumanSignal/label-studio-sdk/blob/master/.github/workflows/lint.yml)).

This would need to be a `.pre-commit-config.yaml` at the base of the repo. Here's the example from [black's docs](https://black.readthedocs.io/en/stable/integrations/source_version_control.html):

```yaml
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](https://pre-commit.ci/lite.html) (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 :smile_cat:

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.