-
Notifications
You must be signed in to change notification settings - Fork 2
/
.pre-commit-config.yaml
67 lines (63 loc) · 2.54 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
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
# Formatting
- id: end-of-file-fixer # Makes sure files end in a newline and only a newline.
- id: pretty-format-json
args: [
'--autofix',
'--indent=4',
'--no-ensure-ascii',
'--no-sort-keys'
] # Formats and sorts your JSON files.
- id: trailing-whitespace # Trims trailing whitespace.
# Checks
- id: check-json # Attempts to load all json files to verify syntax.
- id: check-merge-conflict # Check for files that contain merge conflict strings.
- id: check-shebang-scripts-are-executable # Checks that scripts with shebangs are executable.
- id: check-yaml
# only checks syntax not load the yaml:
# https://stackoverflow.com/questions/59413979/how-exclude-ref-tag-from-check-yaml-git-hook
args: [ '--unsafe' ] # Parse the yaml files for syntax.
# reorder-python-imports ~ sort python imports
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.6.0
hooks:
- id: reorder-python-imports
# black ~ Formats Python code
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args: [
'--line-length=120'
]
# flake8 ~ Enforces the Python PEP8 style guide
# Configure the pep8-naming flake plugin to recognise @classmethod, @validator, @root_validator as classmethod.
# Ignore the unused imports (F401) for the __init__ files, the imports are not always used inside the file,
# but used to setup how other files can import it in a more convenient way.
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
args: [
'--classmethod-decorators=classmethod,validator,root_validator',
'--ignore=E203,W503',
'--max-line-length=120',
'--per-file-ignores=__init__.py:F401'
]
additional_dependencies: [ 'pep8-naming==0.12.1' ]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
hooks:
- id: mypy
language_version: python
# No reason to run if only tests have changed. They intentionally break typing.
exclude: tests/.*
# Pass mypy the entire folder because a change in one file can break others.
args: [--config-file=pyproject.toml, src/]
# Don't pass it the individual filenames because it is already doing the whole folder.
pass_filenames: false
additional_dependencies:
- pydantic