-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.pre-commit-config.yaml
80 lines (73 loc) · 2.82 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
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
# Run with `poetry run pre-commit run --all-files`
repos:
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: remove-crlf
- id: remove-tabs
- id: insert-license
files: \.py$
args:
- --license-filepath
- COPYRIGHT.txt
- --use-current-year
- --no-extra-eol # see below
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.7.3
hooks:
# Run the linter.
- id: ruff
types_or: [ python, pyi, jupyter ]
args: [ --fix ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi, jupyter ]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
additional_dependencies: [ "mypy_extensions", "types-python-dateutil" ] # run mypy --install-types to discover missing types to add here
# Strip output from all jupyter notebooks, except those stored in the docs/ directory.
# We consider everything except documentation to be source code, and source notebooks should not contain outputs.
- repo: local
hooks:
- id: nbstripout
name: nbstripout
entry: poetry run nbstripout --extra-keys metadata.kernelspec
require_serial: true
language: system
files: ^(?!docs\/).*\.ipynb$ # python regex for paths to include - everything except docs/**/*.ipynb
# Bandit is a tool for finding common security issues in Python code. See https://github.com/PyCQA/bandit
# Tip: add `#nosec` to lines of code to ignore checks for that line
- repo: https://github.com/PyCQA/bandit
rev: 1.7.10
hooks:
- id: bandit
# args to use pyproject.toml for project-specific config, run on all files, only show >= medium severity (-ll), and >= medium confidence (-ii), output to screen, silence logging (-q) and aggregate errors by file.
args: [ "-c", "pyproject.toml", "--recursive", "-ll", "-ii", "--format", "screen", "-q", "–aggregate", "file", "src/" ]
additional_dependencies: [ "bandit[toml]" ]
# A few basic checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
exclude_types:
- jupyter
- id: check-yaml
- id: check-added-large-files
args: [ '--maxkb=2048' ]
- id: mixed-line-ending
- id: detect-private-key
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: name-tests-test
args: [ '--pytest-test-first' ]
- repo: https://github.com/python-poetry/poetry
rev: 1.8.0
hooks:
- id: poetry-check