-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.pre-commit-config.yaml
109 lines (99 loc) · 4.44 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
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: local
# hooks:
# - id: pytest-check # Runs pytest on the codebase to execute tests
# name: pytest-check
# entry: pytest
# 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-xml # Validates XML files syntax
- id: check-json # Validates JSON 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: 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
exclude: ^tests/.*__.*\.py$ # Exclude non-test files containing "__" from the check rules
- id: no-commit-to-branch # Prevents committing to specified branches (e.g.: main, master)
args: ["--branch", "master"]
- id: requirements-txt-fixer # Ensures requirements.txt files are formatted correctly
files: "requirements.txt"
- 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},
comments: {min-spaces-from-content: 1}
}}",
]
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.1
hooks:
- id: autoflake # removes unused imports and unused variables
args: # Skips processing of __init__.py files to avoid unintended removal of imports // Modifies files in-place
[--remove-all-unused-imports, --ignore-init-module-imports, --in-place]
- 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"]
- 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/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,*.svg,*.ipynb,*.csv" --ignore-words ignore-spelling-words.txt
language: python
types: [text]
- 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
- id: black-jupyter # Formats Python Jupyter code
args: ["--line-length", "120"] # Allows lines up to 120 characters
- repo: https://github.com/sqlfluff/sqlfluff
rev: 3.2.0
hooks:
- id: sqlfluff-lint # Ensures SQL code adheres to the standards (dialect-specific rules, formatting styles, etc.)
args: [--config, "./pyproject.toml"]
- id: sqlfluff-fix # Automatically formats SQL files according to the specified dialect and rules
args: [--config, "./pyproject.toml"]