Skip to content

Might Be Nice If This Repo. Used pre-commit #44

@O957

Description

@O957

Came here off of LW.

I want to mention that I think it would be nice if this repository used pre-commit hooks for linting and formatting.

You can find supported hooks here.

An example setup that I use in my repositories (at the top level, in .pre-commit-config.yaml; some sections are commented out depending on my needs):

repos:
################################################################################
# General
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.6.0
    hooks:
    -   id: check-added-large-files
    -   id: check-yaml
        args: [--allow-multiple-documents]
    -   id: check-toml
    -   id: end-of-file-fixer
    -   id: mixed-line-ending
    -   id: trailing-whitespace
################################################################################
# Python
-   repo: https://github.com/psf/black-pre-commit-mirror
    rev: 24.3.0
    hooks:
    -   id: black-jupyter
        args: ['--line-length', '79']
        language_version: python3
-   repo: https://github.com/PyCQA/isort
    rev: 5.13.2
    hooks:
    -   id: isort
        args: ['--profile', 'black',
               '--line-length', '79']
-   repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.3.6
    hooks:
      - id: ruff
        args: ['--ignore=E741', '--ignore=E731', '--fix']
################################################################################
# Secrets
# -   repo: https://github.com/Yelp/detect-secrets
#     rev: v1.4.0
#     hooks:
#     -   id: detect-secrets
#         args: ['--baseline', '.secrets.baseline']
#         exclude: package.lock.json
################################################################################
# GitHub Actions
-   repo: https://github.com/rhysd/actionlint
    rev: v1.6.27
    hooks:
    -   id: actionlint
################################################################################
# Make Files
# -   repo: https://github.com/mrtazz/checkmake.git
#     rev: 0.2.2
#     hooks:
#     -   id: checkmake
################################################################################
# Typos
-   repo: https://github.com/crate-ci/typos
    rev: v1.20.7
    hooks:
    -   id: typos
################################################################################
# Commit Messages
-   repo: https://github.com/commitizen-tools/commitizen
    rev: v3.22.0
    hooks:
    -   id: commitizen
################################################################################

You can also add branch protection such that the pre-commit statuses must pass before a PR can be merged. Finally, for configuring workflows and or actions in .github, you can reference this example.

Also, nice work! I would like to engage with this some more, when I get more time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions