-
Notifications
You must be signed in to change notification settings - Fork 1
/
.pre-commit-config.yaml
96 lines (96 loc) · 3.41 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
# Exclude hidden files, init, tensorrt folders, protobuf generated files, markdown files, and DB model.py files
exclude: ^(.*/\..*|.*__init__.py|.*_pb2.py|.*_pb2_grpc.py|.*.md|.*.database.*.models.py)$
default_language_version:
python: python3.9
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: no-commit-to-branch # Prevents direct commits to master
stages: [commit]
- id: check-ast # check if valid python file
stages: [commit]
- id: check-merge-conflict # check if left in merge conflict lines
stages: [commit]
- id: debug-statements # check if left in debug statements
stages: [commit]
- id: trailing-whitespace # remove trailing whitespace
stages: [commit]
- id: end-of-file-fixer # have one line at end of file
stages: [commit]
- id: check-docstring-first # File comments should come before imports
stages: [commit]
- id: check-json # make sure valid json
stages: [commit]
- id: check-yaml # make sure valid yaml
stages: [commit]
- id: name-tests-test # check that tests start with test_*
args: ['--django']
stages: [commit]
- id: requirements-txt-fixer # sort requirements
stages: [commit]
- id: check-added-large-files # check that we're not committing big files to git, excluding lfs files.
args: ['--maxkb=1000'] # set max file size to 1000KB
stages: [commit]
- repo: https://github.com/asottile/pyupgrade # use Python3 tricks
rev: v2.32.0
hooks:
- id: pyupgrade
args: ['--keep-percent-format', '--keep-runtime-typing']
stages: [commit]
- repo: https://github.com/pre-commit/mirrors-isort # Sort imports, similar to PyCharm organize imports
rev: v5.10.1
hooks:
- id: isort
args: ['--line-length=120', '--profile=black']
stages: [commit]
- id: isort
args: ['--line-length=120', '--profile=black', '--check']
stages: [manual]
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args: ['--line-length=120', '--skip-string-normalization']
stages: [commit]
- id: black
args: ['--line-length=120', '--skip-string-normalization', '--check']
stages: [manual]
- repo: https://github.com/pycqa/flake8 # Check for pep8
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies:
- flake8-docstrings
- flake8-pytest-style
args: ['--config=.flake8']
stages: [commit, manual]
- repo: https://github.com/aflc/pre-commit-jupyter
rev: v1.2.1
hooks:
- id: jupyter-notebook-cleanup
args:
- --remove-kernel-metadata
- --pin-patterns
- "[pin];[donotremove]"
stages: [commit]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.942'
hooks:
- id: mypy
additional_dependencies:
- types-protobuf==3.17.4
- types-cachetools==5.0.1
- types-ujson==4.2.1
- types-requests==2.27.20
- types-mock==4.0.13
- numpy==1.22.3
args:
- --config-file=.mypy.ini
- --ignore-missing-imports # silence all import errors from untyped libraries
- --follow-imports=silent # follow imports but suppress all errors
- --strict # enable strict flags (e.g. untyped calls, decorators, optional)
- --allow-subclassing-any # allow subclassing from classes in silenced modules
- --show-column-numbers # add column offsets to error messages
- --allow-untyped-decorators # allow decorating typed functions with untyped decorators
stages: [commit, manual]