From 9584fa9b39bd276c97830a4753791a94afd8e9f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Kulh=C3=A1nek?= Date: Thu, 18 May 2023 16:13:58 +0200 Subject: [PATCH] Add pre-commit (#1949) * Add pre-commit * Add pre-commit to docs --------- Co-authored-by: Brent Yi --- .pre-commit-config.yaml | 27 +++++++++++++++++++++++++++ docs/reference/contributing.md | 4 +++- pyproject.toml | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..4ccc2a61f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,27 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +default_language_version: + python: python3 +repos: +- repo: local + hooks: + - id: add-license-headers + name: add-license-headers + entry: nerfstudio/scripts/licensing/license_headers.sh + language: script + files: '.*' + pass_filenames: false +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer +- repo: https://github.com/charliermarsh/ruff-pre-commit + # Ruff version. + rev: 'v0.0.267' + hooks: + - id: ruff +- repo: https://github.com/psf/black + rev: '23.3.0' + hooks: + - id: black diff --git a/docs/reference/contributing.md b/docs/reference/contributing.md index dd0fdf5b4..529d154eb 100644 --- a/docs/reference/contributing.md +++ b/docs/reference/contributing.md @@ -26,14 +26,16 @@ Below are the various tooling features our team uses to maintain this codebase. ## Requirements -To install the required packages: +To install the required packages and register the pre-commit hook: ```bash pip install -e .[dev] pip install -e .[docs] +pre-commit install ``` This will ensure you have the required packages to run the tests, linter, build the docs, etc. +The pre-commit hook will ensure your commits comply with the repository's code style rules. You may also need to install [pandoc](https://pandoc.org/). If you are using `conda` you can run the following: diff --git a/pyproject.toml b/pyproject.toml index e4647ed93..adcf7ea3d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,6 +74,7 @@ gen = [ # Development packages dev = [ "black[jupyter]==23.3.0", + "pre-commit==3.3.2", "pytest==7.1.2", "pytest-xdist==2.5.0", "typeguard==2.13.3",