generated from myrontuttle/python-codespace
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.pre-commit-config.yaml
99 lines (90 loc) · 3.22 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
default_language_version:
python: python3.9
default_stages: [commit, push]
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.252'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: check-yaml
- id: check-added-large-files
- id: end-of-file-fixer
exclude: LICENSE
- id: no-commit-to-branch
name: Don't commit to main or master branch
description: Prevent the user from committing directly to the primary branch.
# verify that pyproject.toml is well formed
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.12.1
hooks:
- id: validate-pyproject
name: Validate syntax of pyproject.toml
description: Verify that pyproject.toml adheres to the established schema.
- repo: https://github.com/pdm-project/pdm
rev: 2.5.3
hooks:
- id: pdm-lock-check
# Automatically sort the imports used in .py files
- repo: local
hooks:
- id: isort
name: isort (python files in src/ and tests/)
description: Sort and organize imports in .py files.
entry: pdm run isort --settings-path pyproject.toml
types: [python]
language: python
files: ^(src|tests)/
# Analyze the code style and report code that doesn't adhere.
- repo: local
hooks:
- id: black
name: black
entry: pdm run black --config pyproject.toml
types: [python]
files: ^(src|tests)/
language: python
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.9
# Run unit tests, verify that they pass. Note that coverage is run against
# the ./src directory here because that is what will be committed. In the
# github workflow script, the coverage is run against the installed package
# and uploaded to Codecov by calling pytest like so:
# `python -m pytest --cov=<package_name> --cov-report=xml`
- repo: local
hooks:
- id: pytest-check
name: pytest-check
description: Run unit tests with pytest.
entry: make unit-test
language: system
pass_filenames: false
always_run: true
types: [python]
- repo: local
hooks:
- id: sphinx-build
name: Build documentation with Sphinx
entry: pdm run sphinx-build
language: system
always_run: true
exclude_types: [file, symlink]
args:
[
"-T", # Show full trace back on exception
"-E", # Don't use saved env. always read all files.
"-b", # Flag to select which builder to use
"html", # Use the HTML builder
"-d", # Flag for cached environment and doctrees
"docs/build/doctrees", # directory
"./docs", # Source directory of documents
"docs/build/html", # Output directory for rendered documents.
]