forked from catalyst-cooperative/pudl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.pre-commit-config.yaml
161 lines (145 loc) · 5.43 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
---
repos:
# Quick content checks based on grepping for python specific patterns:
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-check-blanket-noqa # Prohibit overly broad QA exclusions.
- id: python-no-eval # Never use eval() it's dangerous.
- id: python-no-log-warn # logger.warning(), not old .warn()
- id: rst-backticks # Find single rather than double backticks
- id: rst-directive-colons # Missing double-colons after directives
- id: rst-inline-touching-normal # Inline code should never touch normal text
- id: python-use-type-annotations # Use annotations not old-style type comments
# Other file formatting, plus common Git mistakes & text file standardization:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-added-large-files # Don't accidentally commit giant files.
- id: check-merge-conflict # Watch for lingering merge markers.
- id: check-yaml # Validate all YAML files.
- id: check-case-conflict # Avoid case sensitivity in file names.
- id: debug-statements # Watch for lingering debugger calls.
- id: end-of-file-fixer # Ensure there's a newline at EOF.
- id: mixed-line-ending # Only newlines, no line-feeds.
- id: trailing-whitespace # Remove trailing whitespace.
- id: name-tests-test # Follow PyTest naming convention.
####################################################################################
# Formatters: hooks that re-write Python & documentation files
####################################################################################
# Make sure import statements are sorted uniformly.
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
# Format the code
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
language_version: python3.10
# Format docstrings
- repo: https://github.com/PyCQA/docformatter
rev: v1.5.0
hooks:
- id: docformatter
args: ["--in-place", "--config", "tox.ini"]
# Remove f-string prefix when there's nothing in the string to format.
- repo: https://github.com/dannysepler/rm_unneeded_f_str
rev: v0.1.0
hooks:
- id: rm-unneeded-f-str
# Use built-in types for annotations as per PEP585
- repo: https://github.com/sondrelg/pep585-upgrade
rev: v1.0
hooks:
- id: upgrade-type-hints
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.4
hooks:
- id: prettier
types_or: [yaml]
# Update Python language constructs to modern standards
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
hooks:
- id: pyupgrade
args: ["--py310-plus"]
####################################################################################
# Linters: hooks that check but don't alter Python and documentation files
####################################################################################
# Check for PEP8 non-compliance, code complexity, style, errors, etc:
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
args: [--config, tox.ini]
additional_dependencies:
- flake8-docstrings
- flake8-colors
- pydocstyle
- flake8-builtins
- mccabe
- pep8-naming
- pycodestyle
- pyflakes
- flake8-rst-docstrings
- flake8-use-fstring
# Check for known security vulnerabilities:
- repo: https://github.com/PyCQA/bandit
rev: 1.7.4
hooks:
- id: bandit
args: ["--configfile", ".bandit.yml"]
# Lint Dockerfiles for errors and to ensure best practices
- repo: https://github.com/AleksaC/hadolint-py
rev: v2.10.0
hooks:
- id: hadolint
# Check for errors in restructuredtext (.rst) files under the doc hierarchy
- repo: https://github.com/PyCQA/doc8
rev: v1.0.0
hooks:
- id: doc8
args: [--config, tox.ini]
# Lint any RST files and embedded code blocks for syntax / formatting errors
- repo: https://github.com/rstcheck/rstcheck
rev: v6.1.1
hooks:
- id: rstcheck
additional_dependencies: [sphinx]
args: [--config, tox.ini]
#####################################################################################
# Our own pre-commit hooks, which don't come from the pre-commit project
#####################################################################################
- repo: local
hooks:
- id: nb-output-clear
name: nb-output-clear
stages: [commit]
language: system
verbose: false
pass_filenames: false
always_run: true
entry:
find devtools \( -name \*.ipynb -not -name \*checkpoint.ipynb \) -type
f -exec jupyter nbconvert --clear-output {} \;
- id: unit-tests
name: unit-tests
stages: [commit]
language: system
verbose: false
pass_filenames: false
always_run: true
entry: pytest --doctest-modules src/pudl test/unit
# Configuration for pre-commit.ci
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks
For more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_branch: dev
autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate"
autoupdate_schedule: weekly
skip: [unit-tests, nb-output-clear]
submodules: false