-
Notifications
You must be signed in to change notification settings - Fork 1
/
.pre-commit-config.yaml
106 lines (98 loc) · 3.72 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
# YAML formatting specifications: https://yaml.org/spec/1.2.2/
repos:
# Syntax validation and some basic sanity checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0 # Released 2023-10-09
# rev input based on version tag format in repo (e.g. with or without 'v')
hooks:
- id: check-added-large-files
name: Checking for added large files
args: ["--maxkb=200"]
fail_fast: True
- id: check-case-conflict
name: Checking for name case conflicts
- id: check-merge-conflict
name: Checking for merge conflicts
- id: check-ast
name: Verifying Python file syntax
- id: check-json
name: Verifying JSON file syntax
- id: check-yaml
name: Verifying YAML file syntax
args: [--allow-multiple-documents]
- id: check-toml
name: Verifying TOML file syntax
# Format the pyproject.toml file
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 1.7.0 # Released 2024-01-22
hooks:
- id: pyproject-fmt
name: Formatting the pyproject.toml file
additional_dependencies: ["tox>=4.9"]
# Automatic source code formatting
- repo: https://github.com/psf/black
rev: 24.3.0 # Released 2024-03-15
hooks:
- id: black
name: Formatting Python scripts according to Black
args: [--safe, --quiet]
# Automatically sort imports
- repo: https://github.com/PyCQA/isort
rev: 5.13.2 # Released 2023-12-13
hooks:
- id: isort
name: Tidying Python imports via Isort
args: [
#'-a', 'from __future__ import annotations', # 3.7-3.11
"--rm",
"from __future__ import absolute_import", # -3.0
"--rm",
"from __future__ import division", # -3.0
"--rm",
"from __future__ import generator_stop", # -3.7
"--rm",
"from __future__ import generators", # -2.3
"--rm",
"from __future__ import nested_scopes", # -2.2
"--rm",
"from __future__ import print_function", # -3.0
"--rm",
"from __future__ import unicode_literals", # -3.0
"--rm",
"from __future__ import with_statement", # -2.6
]
# Linting
- repo: https://github.com/PyCQA/flake8
# Release history: https://flake8.pycqa.org/en/latest/release-notes/index.html
rev: 7.0.0 # Released 2024-01-05
hooks:
- id: flake8
name: Running Flake8 linter on Python files
additional_dependencies: [
# Added Flake8-pyproject plugin for .toml compatibility
"Flake8-pyproject==1.2.3", # Released 2023-03-21
# flake8-comprehensions URL: https://github.com/adamchainz/flake8-comprehensions
"flake8-comprehensions==3.14.0", # Released 2023-07-10
]
# Type checking
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0 # Released 2024-03-09
hooks:
- id: mypy
name: Checking types in Python scripts using MyPy
files: '(src|tests)/.*\.py$' # RegEx string showing directories and files to check
# Single quote critical due to escape character '\' used in the search string
# (see YAML specifications - 7.3 Flow Scalar Styles)
additional_dependencies: [
# Install missing stub packages
types-requests,
types-xmltodict,
types-PyYAML,
]
# Use Prettier to format other files
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0 # Released 2023-11-13 | Latest stable version
hooks:
- id: prettier
name: Formatting other file types according to Prettier
# types_or: [css, html, json, yaml]