-
Notifications
You must be signed in to change notification settings - Fork 0
/
.pre-commit-config.yaml
160 lines (152 loc) · 6.4 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
repos:
- repo: local
hooks:
- id: unittest-check # Runs unittest on the codebase to execute tests
name: unittest-check
entry: python -m unittest discover -s tests --verbose
language: system
pass_filenames: false
always_run: true
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace # Removes trailing whitespace
- id: end-of-file-fixer # Ensures files end with a newline
- id: check-yaml # Validates YAML config files
- id: check-toml # Validates TOML config files
- id: check-json # Validates JSON files
- id: check-xml # Validates XML files syntax
- id: check-added-large-files # Prevents large files from being added
- id: check-merge-conflict # Detects merge conflict markers
- id: check-case-conflict # Detects case conflicts in filenames
- id: check-ast # Validates Python files for syntax errors
- id: detect-private-key # Prevents private keys from being committed
- id: check-docstring-first # Checks if module-level docstring is present and at the beginning file.
- id: debug-statements # Identifies the usage of debugging statements like print, pdb, etc.
- id: name-tests-test # Verifies that test files are named correctly.
args: ["--pytest-test-first"] # Ensure tests match test_.*\.py
- id: requirements-txt-fixer # Ensures requirements.txt files are formatted correctly
files: "requirements.txt|requirements-dev.txt"
# - id: no-commit-to-branch # Prevents committing to specified branches
# args: ["--branch", "main", "--branch", "master"]
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint # Lints YAML files for style and syntax
args: # Allows lines up to 120 characters, ignores rule of '---' at the beginning of the file
["-d", "{extends: default, rules: {line-length: {max: 120}, document-start: {present: false}}}"]
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort # Sorts Python imports
args: # Adheres to black formatting style, max line length 120 characters
["--profile", "black", "--line-length", "120"]
language_version: python3.11
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell # Spell checking - checks for common misspellings in text files
name: codespell
description: Checks for common misspellings in text files.
entry: codespell --skip="*.js,*.html,*.css, *.csv, *.svg" --ignore-words ignore-spelling-words.txt
language: python
types: [text]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier # Formats JSON, YAML, and Markdown files
files: \.(json|yaml|yml|md)$
args: ["--print-width", "120"]
- repo: https://github.com/google/yapf
rev: v0.40.2
hooks:
- id: yapf # Google formatter to keep PEP 8 rules
name: yapf
args: [--style, google]
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black # Formats Python code to adhere to PEP 8
args: ["--line-length", "120"] # Allows lines up to 120 characters
language_version: python3.11
- id: black-jupyter # Formats Python Jupyter code
args: ["--line-length", "120"] # Allows lines up to 120 characters
language_version: python3.11
# ============================================================================================================
# ================ From this point we raise the bar with more strict rules, comment if needed ================
# ============================================================================================================
#
# - repo: https://github.com/hhatto/autopep8
# rev: v2.3.0
# hooks:
# - id: autopep8 # Automatically formats Python code to conform to the PEP 8 style guide
#
# # Security checks
# - repo: https://github.com/Lucas-C/pre-commit-hooks-safety
# rev: v1.3.3
# hooks:
# - id: python-safety-dependencies-check # Checks Python dependencies for known security vulnerabilities
# files: pip_requirements.txt, pip_dev_requirements.txt, pip_doc_requirements.txt, pyproject.toml
#
# - repo: https://github.com/PyCQA/bandit
# rev: 1.7.9
# hooks:
# - id: bandit # Security linter for Python code
# additional_dependencies: ["toml"]
#
#
#
# # Linters and formatters
#
# - repo: https://github.com/asottile/add-trailing-comma
# rev: v3.1.0
# hooks:
# - id: add-trailing-comma # Adds trailing commas to multiline collections
#
# - repo: https://github.com/astral-sh/ruff-pre-commit
# rev: v0.4.9
# hooks:
# - id: ruff # Run the ruff linter
# args: [ "--fix", "--line-length=120" ]
# - id: ruff-format # Run the ruff formatter
# args: [ "--line-length=120" ]
#
# - repo: https://github.com/PyCQA/pydocstyle
# rev: 6.3.0
# hooks:
# - id: pydocstyle # Ensures compliance with Python docstring conventions
#
# - repo: https://github.com/PyCQA/flake8
# rev: 7.1.0
# hooks:
# - id: flake8 # Checks Python code for style and quality issues
# additional_dependencies: [flake8-bugbear, flake8-docstrings]
# args: # Allows lines up to 120 characters, ignores missing docstring warnings
# [
# "--max-line-length=120",
# "--ignore=D100,D101,D102,D103,D104,D105,D107",
# ]
#
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.10.0
# hooks:
# - id: mypy # Static type checker for Python
# additional_dependencies: [types-all]
#
# - repo: https://github.com/pylint-dev/pylint
# rev: v3.2.3
# hooks:
# - id: pylint # Checks Python code for errors and coding standards
# # Allows lines up to 120 characters, ignores missing docstring warnings
# args: [ "--max-line-length=120", "--disable=C0111" ]
#
# - repo: https://github.com/asottile/pyupgrade
# rev: v3.16.0
# hooks:
# - id: pyupgrade # Upgrades syntax for newer versions of Python
# args: [ "--py310-plus" ]
#
# - repo: https://github.com/asottile/setup-cfg-fmt
# rev: v2.5.0
# hooks:
# - id: setup-cfg-fmt # Formats setup.cfg files