-
Notifications
You must be signed in to change notification settings - Fork 2
/
.pre-commit-config.yaml
135 lines (120 loc) · 4.79 KB
/
.pre-commit-config.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
fail_fast: true
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
# - id: check-docstring-first
- id: check-json
- id: check-yaml
- id: pretty-format-json
exclude: \.ipy(n|nb)$
args: ["--autofix", "--indent=2", "--no-sort-keys"]
# Compare the local template version to the latest remote template version
# This hook should always pass. It will print a message if the local version
# is out of date.
- repo: https://github.com/lincc-frameworks/pre-commit-hooks
rev: v0.1.1
hooks:
- id: check-lincc-frameworks-template-version
name: Check template version
description: Compare current template version against latest
verbose: true
# Clear output from jupyter notebooks so that only the input cells are committed.
- repo: local
hooks:
- id: jupyter-nb-clear-output
name: Clear output from Jupyter notebooks
description: Clear output from Jupyter notebooks.
files: \.ipynb$
stages: [commit]
language: system
entry: jupyter nbconvert --clear-output
# Prevents committing directly branches named 'main' and 'master'.
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: no-commit-to-branch
name: Prevent main branch commits
description: Prevent the user from committing directly to the primary branch.
- id: check-added-large-files
name: Check for large files
description: Prevent the user from committing very large files.
args: ['--maxkb=500']
# Verify that pyproject.toml is well formed
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.12.1
hooks:
- id: validate-pyproject
name: Validate pyproject.toml
description: Verify that pyproject.toml adheres to the established schema.
# Automatically sort the imports used in .py files
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: Run isort
description: Sort and organize imports in .py and .pyi files.
types_or: [python, pyi]
# Analyze the code style and report code that doesn't adhere.
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black-jupyter
name: Format code using black
types_or: [python, pyi, jupyter]
# 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
# Analyze type hints and report errors.
- repo: local
hooks:
- id: mypy
name: mypy (python files in src/ and tests/)
entry: mypy
language: system
types: [python]
files: ^(src|tests)/
# Run unit tests, verify that they pass. Note that coverage is run against
# the ./src directory here because that is what will be committed. In the
# github workflow script, the coverage is run against the installed package
# and uploaded to Codecov by calling pytest like so:
# `python -m pytest --cov=<package_name> --cov-report=xml`
- repo: local
hooks:
- id: pytest-check
name: Run unit tests
description: Run unit tests with pytest.
entry: bash -c "if python -m pytest --co -qq; then python -m pytest --cov=./src --cov-report=html; fi"
language: system
pass_filenames: false
always_run: true
# Make sure Sphinx can build the documentation while explicitly omitting
# notebooks from the docs, so users don't have to wait through the execution
# of each notebook or each commit. By default, these will be checked in the
# GitHub workflows.
- repo: local
hooks:
- id: sphinx-build
name: Build documentation with Sphinx
entry: sphinx-build
language: system
always_run: true
exclude_types: [file, symlink]
args:
[
"-M", # Run sphinx in make mode, so we can use -D flag later
# Note: -M requires next 3 args to be builder, source, output
"html", # Specify builder
"./docs", # Source directory of documents
"./_readthedocs", # Output directory for rendered documents
"-T", # Show full trace back on exception
"-E", # Don't use saved env; always read all files
"-d", # Flag for cached environment and doctrees
"./docs/_build/doctrees", # Directory
"-D", # Flag to override settings in conf.py
"exclude_patterns=notebooks/*", # Exclude our notebooks from pre-commit
]