forked from gerardpslowey/eMot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.pre-commit-config.yaml
179 lines (169 loc) · 7.78 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
##########################################################################################
# #
# Pre-commit configuration file #
# #
##########################################################################################
---
default_language_version:
python: python3
repos:
####################################### Various Checks ###############################
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-ast
name: check-ast
description: Simply check whether files parse as valid python.
- id: check-builtin-literals
name: check-builtin-literals
description: Require literal syntax when initializing empty,
or zero Python builtin types.
- id: check-docstring-first
name: check-docstring-first
description: Checks for a common error of placing code before the docstring.
- id: check-added-large-files
name: check-added-large-files
args: ['--maxkb=3000']
description: Prevent giant files from being committed.
- id: check-merge-conflict
name: check-merge-conflict
description: Check for files that contain merge conflict strings.
- id: check-yaml
name: check-yaml
description: Attempts to load all yaml files to verify syntax.
- id: debug-statements
name: debug-statements
description: Check for debugger imports and py37+ breakpoint() calls in python source.
- id: detect-private-key
name: detect-private-key
description: Checks for the existence of private keys.
- id: end-of-file-fixer
name: end-of-file-fixer
description: Makes sure files end in a newline and only a newline.
- id: trailing-whitespace
name: trailing-whitespace
description: Trims trailing whitespace
- id: requirements-txt-fixer
name: requirements-txt-fixer
description: Sorts entries in requirements.txt
- repo: local
hooks:
# Python minor syntax related checks
# https://github.com/Pike/pygrep
- id: python-check-mock-methods
name: python-check-mock-methods
description: Prevent common mistakes of `assert mck.not_called()`, `assert mck.called_once_with(...)`
and `mck.assert_called`.
language: pygrep
entry: >
(?x)(
assert .*\.(
not_called|
called_
)|
\.assert_(
any_call|
called|
called_once|
called_once_with|
called_with|
has_calls|
not_called
)($|[^(\w])
)
types: [python]
- id: python-no-eval
name: python-no-eval
description: 'A quick check for the `eval()` built-in function'
entry: '\beval\('
language: pygrep
types: [python]
- id: python-no-log-warn
name: python-no-log-warn
description: 'A quick check for the deprecated `.warn()` method of python loggers'
entry: '(?<!warnings)\.warn\('
language: pygrep
types: [python]
- id: python-use-type-annotations
name: python-use-type-annotations
description: 'Enforce that python3.6+ type annotations are used instead of type comments'
entry: '# type(?!: *ignore *($|#))'
language: pygrep
types: [python]
# Vulture
# https://github.com/jendrikseipp/vulture
- id: vulture
name: vulture
description: Find dead Python code
entry: vulture
args: [
"--min-confidence", "100",
"--exclude", "env/", "src/pyqt",
".",
]
language: system
types: [python]
####################################### Linters ######################################
- repo: local
hooks:
# Flake8 Linter
# https://flake8.pycqa.org/en/latest/
- id: flake8
name: flake8
description: Python style guide enforcement
entry: flake8
args: ["--max-line-length=120", "--ignore=E401,E402,D100,D102,D103,D205,D107,DUO103,D401,N802,N803,N806,N815,PD005,PD011,VNE001,W503,W504"]
exclude: env, models, modelTrain, textMod
additional_dependencies: [
flake8-2020, # flake8 plugin which checks for misuse of `sys.version` or `sys.version_info`
flake8-blind-except, # A flake8 extension that checks for blind except: statements
flake8-bugbear, # A plugin for flake8 finding likely bugs and design problems in your program.
# Contains warnings that don't belong in pyflakes and pycodestyle.
flake8-builtins, # Check for python builtins being used as variables or parameters.
flake8-comprehensions, # It helps you write a better list/set/dict comprehensions.
flake8-copyright, # Adds copyright checks to flake8
flake8-deprecated, # Warns about deprecated method calls.
dlint, # Dlint is a tool for encouraging best coding practices and helping ensure we're writing secure Python code.
flake8-docstrings, # Extension for flake8 which uses pydocstyle to check docstrings
flake8-license,
pandas-vet, # A Flake8 plugin that provides opinionated linting for pandas code
flake8-pytest, # pytest assert checker plugin for flake8
flake8-variables-names, # flake8 extension that helps to make more readable variables names
flake8-tabs, # Tab (or Spaces) indentation style checker for flake8
pep8-naming, # Check PEP-8 naming conventions, plugin for flake8
]
language: python
types: [python]
# ################################### Code Format ######################################
- repo: local
hooks:
# pyupgrade
# Upgrade Python syntax
- id: pyupgrade
name: pyupgrade
description: Automatically upgrade syntax for newer versions of the language.
entry: pyupgrade
args: ['--py3-plus']
language: python
types: [python]
additional_dependencies: [pyupgrade]
# Sort imports
# https://github.com/timothycrosley/isort
- id: isort
name: isort
description: Library to sort imports.
entry: isort
language: python
types: [python]
# pycodestyle code format
# https://pypi.python.org/pypi/autopep8/
- id: autopep8
name: autopep8
description: A tool that automatically formats Python code to conform to the PEP 8 style guide.
entry: autopep8
args: [
'--in-place',
'--aggressive'
]
language: python
types: [python]