-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.pre-commit-config.yaml
139 lines (131 loc) · 5.9 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
############################
# --- Pre-Commit Hooks --- #
############################
# A few good resources:
# file where hooks are installed venv: https://github.com/getsentry/sentry/blob/master/.pre-commit-config.yaml
# for simplicity, we exclude files generated by projen
x-exclude-projen: &projen-exclude-pattern |
(?x)(
^.*projen/|
^.*setup.cfg|
^.*setup.py|
^.*pyproject.toml|
^.*gitignore|
)
repos:
- repo: local
hooks:
- id: update-projen-managed-files
name: update-projen-managed-files
entry: python ./.projenrc.py
language: python
additional_dependencies: ["phitoduck-projen"]
pass_filenames: false
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
# Fails if there are any ">>>>>" lines in files due to merge conflicts.
- id: check-merge-conflict
# Trims trailing whitespace. Allow a single space on the end of .md lines for hard line breaks.
- id: trailing-whitespace
exclude: *projen-exclude-pattern
args: [--markdown-linebreak-ext=md]
# Makes sure files end in a newline and only a newline;
# we include CSV since a lot of the files already in our git LFS store are csv and json
- id: end-of-file-fixer
exclude: *projen-exclude-pattern
exclude_types: [csv, svg]
# Attempts to load all TOML files to verify syntax.
- id: check-toml
# Attempts to load all yaml files to verify syntax; unsafe: only check syntax, do not load yaml
- id: check-yaml
args: ["--unsafe"]
# Check for symlinks that do not point to anything.
- id: check-symlinks
# Fail if staged files are above a certain size.
# To add a large file, use 'git lfs track <file>; git add <file> to track large files with
# git-lfs rather than commiting them directly to the git history
- id: check-added-large-files
args: ["--maxkb=500"]
# HALT! Before you exclude a large file and commit it, forever
# bloating our repo size, did you:
# (1) use a CLI tool like imageoptim to compress them if they are images
# (2) think hard about whether using DVC or git-lfs is more appropriate
# for the file--such as in the case of CSV files or other data
# This can be confusing. Reach out for help in our chat to help decide
# how to deal adding these large files you have :)
exclude: |
(?x)(
^path/to/some/big/file.csv|
^path/to/another/big/file.csv
)
# Sort requirements in requirements.txt files.
- id: requirements-txt-fixer
exclude: *projen-exclude-pattern
# Prevent addition of new git submodules.
- id: forbid-new-submodules
# Prevent committing directly to trunk; create a feature branch for your changes with
# 'git checkout -b feat/my-new-feature' and then commit these changes to that branch
- id: no-commit-to-branch
args: ["--branch=trunk"]
# Detects *your* aws credentials from your ~/.aws/credentials file
- id: detect-aws-credentials
# Detects the presence of private keys
- id: detect-private-key
# - repo: https://github.com/Yelp/detect-secrets
# rev: v1.1.0
# hooks:
# # compare "high entropy" strings found in our code with the last time we did this
# - id: detect-secrets
# args: [--baseline, .secrets.baseline]
# exclude: package.lock.json
# A few helpers for writing reStructuredText (in docstrings and sphinx docs)
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
# Detect common mistake of using single backticks when writing rst
- id: rst-backticks
# Detect mistake of rst directive not ending with double colon
- id: rst-directive-colons
# Detect mistake of inline code touching normal text in rst
- id: rst-inline-touching-normal
- repo: https://github.com/humitos/mirrors-autoflake.git
rev: v1.3
hooks:
# remove ALL unused imports; to protect intentional unused imports, add "# noqa" to the end of a line
- id: autoflake
args:
[
--in-place,
--remove-all-unused-imports,
--remove-unused-variable,
--ignore-init-module-imports,
]
- repo: https://github.com/akaihola/darker
rev: 1.4.1
hooks:
# fail if black, pylint, flake8, isort, or pydocstyle find errors in the 'git --diff'
# between this branch and latest commit on 'trunk'; this is great because it does not require
# contributors to make changes to parts of the codebase they didn't change. Said otherwise:
# if you submit a PR, the build will only fail if the code *you* wrote/changed does not
# satisfy these quality check tools, but if there were already issues in the codebase before
# you got there, the build will still pass and your PR can go through.
- id: darker
args:
- --isort
# executes flake8 and pydocstyle (where pydocstyle is a flake8 plugin)
- -L flake8 --config=./linting/.flake8
- -L pylint --rcfile=./linting/.pylintrc
# line length for black
- -l 112
- --verbose
additional_dependencies:
- black==22.1.0
- isort~=5.9
- flake8~=4.0
- pylint~=2.12
- pydocstyle~=6.1
# pydocstyle plugin for flake8
- flake8-docstrings~=1.6
entry: darker --revision trunk
exclude: *projen-exclude-pattern