MLOS/.pre-commit-config.yaml

176 строки
5.1 KiB
YAML

# Enable automatic updates via Github Actions as well.
# See https://pre-commit.ci
ci:
# Let pre-commit.ci automatically update PRs with formatting fixes.
autofix_prs: true
# skip local hooks - they should be managed manually via conda-envs/*.yml
skip: [mypy, pylint, pycodestyle, pyright]
autoupdate_schedule: monthly
autoupdate_commit_msg: |
[pre-commit.ci] pre-commit autoupdate
for more information, see https://pre-commit.ci
NOTE: Be sure to also check for other possible hook updates in the conda-envs/*.yml files (e.g., mypy, pylint, etc.).
See Also:
- https://github.com/microsoft/MLOS/blob/main/conda-envs/mlos.yml
- https://pypi.org/project/mypy/
- https://pypi.org/project/pyright/
- https://pypi.org/project/pylint/
- https://pypi.org/project/pycodestyle/
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_stages: [pre-commit]
# Note "require_serial" actually controls whether that particular hook's files
# are partitioned and the hook executable called in parallel across them, not
# whether hooks themselves are parallelized.
# As such, some hooks (e.g., pylint) which do internal parallelism need it set
# for efficiency and correctness anyways.
repos:
#
# Formatting
#
# NOTE: checks that adjust files are marked with the special "manual" stage so
# that we can easily call them via `make`.
#
#
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
# - id: check-executables-have-shebangs (issues in devcontainer)
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
stages: [pre-commit, manual]
- id: trailing-whitespace
stages: [pre-commit, manual]
- repo: https://gitlab.com/bmares/check-json5
rev: v1.0.0
hooks:
- id: check-json5
alias: check-json
types_or: [file, json]
files: '\.json[c]?$'
# FIXME: This removes comments.
# See Also: https://github.com/dpranke/pyjson5/issues/28
#- repo: https://github.com/whtsky/pre-commit-pretty-format-json5
# rev: "1.0.0"
# hooks:
# - id: pretty-format-json5
# alias: pretty-format-json
# args: [--no-sort-keys]
# stages: [pre-commit, manual]
# types_or: [file, json]
# files: '\.json[c]?$'
- repo: https://github.com/johann-petrak/licenseheaders
rev: v0.8.8
hooks:
- id: licenseheaders
files: '\.(sh|cmd|ps1|sql|py)$'
args: [-t, doc/mit-license.tmpl, -E, .py, .sh, .ps1, .sql, .cmd, -x, mlos_bench/setup.py, mlos_core/setup.py, mlos_viz/setup.py, -f]
stages: [pre-commit, manual]
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
hooks:
- id: pyupgrade
args: [--py310-plus]
stages: [pre-commit, manual]
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
require_serial: true
args: ["-j", "-1"]
stages: [pre-commit, manual]
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
stages: [pre-commit, manual]
- repo: https://github.com/PyCQA/docformatter
rev: 06907d0 # v1.7.5
hooks:
- id: docformatter
stages: [pre-commit, manual]
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: mdformat
additional_dependencies:
- mdformat-gfm
- mdformat-black
- mdformat_frontmatter
- mdformat-toc
#
# Linting
#
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
types: [python]
additional_dependencies:
- tomli
# Use pylint and mypy from the local (conda) environment so that vscode can reuse them too.
- repo: local
hooks:
- id: pycodestyle
name: pycodestyle
entry: pycodestyle
language: system
types: [python]
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
require_serial: true
args: [
"-j0",
"--rcfile=pyproject.toml",
"-rn", # Only display messages
"-sn", # Don't display the score
]
exclude: |
(?x)^(
doc/source/conf.py
)$
- id: pyright
name: pyright
entry: pyright
language: system
types: [python]
require_serial: true
exclude: |
(?x)^(
doc/source/conf.py|
mlos_core/setup.py|
mlos_bench/setup.py|
mlos_viz/setup.py|
conftest.py
)$
- id: mypy
name: mypy
entry: mypy
language: system
types: [python]
require_serial: true
exclude: |
(?x)^(
doc/source/conf.py|
mlos_core/setup.py|
mlos_bench/setup.py|
mlos_viz/setup.py|
conftest.py
)$
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes