our_knp/examples/.pre-commit-config.yaml
int 8f43927575 Initial import: KNP experiments (examples, viz, cats-dogs, reports)
examples/ is based on KasperskyLab/knp at 55470ed6 with local changes
to the mnist-learn altai/blifat models, cuda-backend CMake and model_loader.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 18:17:15 +03:00

272 lines
8.3 KiB
YAML

# This file configures https://pre-commit.com/
# Based on pre-commit hooks in
# https://github.com/pre-commit/pre-commit-hooks
# https://github.com/jumanjihouse/pre-commit-hooks
# to use specific hooks and options.
fail_fast: false
repos:
#
# Common
#
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v6.0.0"
hooks:
- id: check-case-conflict
- id: trailing-whitespace
exclude: \.output
- id: end-of-file-fixer
exclude: \.(cp?p?$|output)
- id: check-added-large-files
exclude: doc/html/static/background.mp4
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-yaml
- id: check-toml
#
# Git.
#
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v6.0.0"
hooks:
- id: check-merge-conflict
# - id: no-commit-to-branch
- repo: https://github.com/jorisroovers/gitlint
rev: "v0.19.1"
hooks:
- id: gitlint
#
# C++
#
- repo: https://github.com/pocc/pre-commit-hooks
rev: "v1.3.5"
hooks:
- id: clang-format
args: ["--style=file", "-i"]
additional_dependencies:
[clang-format==15.0.7]
# - id: oclint
# - id: uncrustify
# DO NOT RUN: see comment below (in the local hook description).
#- id: clang-tidy
# name: clang-tidy
# args: ["--config-file=knp/.clang-tidy", "-extra-arg-before=-xc++", "-extra-arg=-std=c++17", "-p=build"]
- id: cppcheck
args: ["-x", "c++", "--inline-suppr", "--template=gcc", "--suppress-xml=knp/.cppcheck-suppress.xml"] # --cppcheck-build-dir=build]
# - id: clang-tidy
# args: ["--config-file=knp/.clang-tidy", "-extra-arg-before=-xc++", "-extra-arg=-std=c++17", "-p=build"]
# additional_dependencies:
# [clang-tidy==18.1.1]
- id: cpplint
args: ["--exclude=tools/python-bindings-gen/py-gen", "--root", "knp"]
additional_dependencies:
[cpplint==1.6.1]
# - id: include-what-you-use
- repo: local
hooks:
# Tidy is not integrated in CMake calls.
# - Bug: cstddef:50:10: error: 'stddef.h' file not found [clang-diagnostic-error].
# - Don't necessary to run tidy on the every build.
# - With a cache tidy is faster.
# - I don't know where is the real build directory.
# - Hook implementation with a cache is buggy now.
# - id: clang-tidy
# name: clang-tidy
# args: ["--config-file=knp/.clang-tidy", "-extra-arg-before=-xc++", "-extra-arg=-std=c++17", "-p=build"]
# entry: tools/hooks/clang_tidy.py
# description: Find warnings/errors in C, C++, and Objective-C code
# additional_dependencies:
# [clang-tidy==18.1.1]
# types_or: [c, c++, g#, objective-c, cuda]
# language: python
# - id: oclint
# name: oclint
# entry: tools/hooks/oclint.py
# description: Find warnings/errors in C, C++, and Objective-C code
# types_or: [c, c++, c#, objective-c]
# language: python
# - id: uncrustify
# name: uncrustify
# entry: tools/hooks/uncrustify.py
# description: Formats C, C++, Objective-C, Java, D, and Vala code
# # D, vala currently aren't valid file types. See https://github.com/pre-commit/identify/issues/258
# types_or: [c, c++, c#, objective-c, java]
# language: python
- id: cloc
name: cloc
entry: tools/hooks/cloc.py
description: Code lines counter
types_or: [c, c++, c#, objective-c, cuda, python, bash]
language: python
- id: cccc
name: cccc
entry: tools/hooks/cccc.py
args: ["--outdir=build/cccc", "--limits_file=knp/.cccc.json"]
description: Code counter for C and C++
types_or: [c, c++, c#, objective-c, cuda]
language: python
#
# CMake
#
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: "v0.6.13"
hooks:
- id: cmake-format
args: ["--config", ".cmake-format.yaml"]
- id: cmake-lint
args: ["--config-files", ".cmake-format.yaml"]
#
# Python
#
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v6.0.0"
hooks:
- id: debug-statements
- id: check-docstring-first
- id: requirements-txt-fixer
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.1
hooks:
- id: autoflake
exclude: &fixtures tests(/\w*)*/functional/|tests/input|doc/data/messages|tests(/\w*)*data/
args:
- --in-place
- --remove-all-unused-imports
- --expand-star-imports
- --remove-duplicate-keys
- --remove-unused-variables
- repo: https://github.com/pycqa/pylint
rev: "v4.0.4" # pylint-2.14.5
hooks:
- id: pylint
args: ["-rn", "-sn", "--rcfile=knp/python-framework/packaging/common/.pylintrc", "--fail-on=I", "--load-plugins=pylint.extensions.docparams"]
exclude: tests(/\w*)*/functional/|tests/input|tests(/\w*)*data/|doc/
- id: pylint
alias: pylint-with-spelling
args: ["-rn", "-sn", "--rcfile=knp/python-framework/packaging/common/.pylintrc", "--fail-on=I", "--spelling-dict=en,ru"]
exclude: tests(/\w*)*/functional/|tests/input|tests(/\w*)*data/|doc/
stages: [manual]
- repo: https://github.com/PyCQA/flake8
rev: 7.3.0
hooks:
- id: flake8
args: ["--config", "knp/.flake8"]
additional_dependencies:
[flake8-bugbear==22.12.6, flake8-typing-imports==1.14.0]
exclude: ".*fixtures"
# Bad: removes blank string after shebang.
# - repo: https://github.com/asottile/reorder_python_imports
# rev: bc7b5b2f0fde191c9d0121588ef9bbb79f8e5e21
# hooks:
# - id: reorder-python-imports
# language_version: python3
- repo: https://github.com/pre-commit/pre-commit
rev: v4.5.1
hooks:
- id: validate_manifest
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.19.1
hooks:
- id: mypy
args: ["--config-file", "knp/.mypy.ini", "--install-types", "--explicit-package-bases", "--check-untyped-defs", "--scripts-are-modules", "--strict"]
additional_dependencies:
[
"isort>=5",
"platformdirs==2.2.0",
"py==1.11",
"tokenize-rt==3.2.0",
"tomlkit>=0.10.1",
"types-pkg_resources==0.1.3",
"types-all",
"types-attrs",
"types-requests",
"types-dataclasses>=0.1.3",
"types-PyYAML",
"types-typed-ast>=1.4.1"
]
exclude: tests(/\w*)*/functional/|tests/input|tests(/.*)+/conftest.py|doc/data/messages|tests(/\w*)*data|python/
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
hooks:
- id: pyupgrade
- repo: https://github.com/ambv/black
rev: "25.12.0"
hooks:
- id: black
args: ["-l", "120", "--skip-string-normalization"]
- repo: https://github.com/DanielNoord/pydocstringformatter
rev: v0.7.5
hooks:
- id: pydocstringformatter
exclude: *fixtures
args: ["--max-summary-lines=2", "--linewrap-full-docstring"]
- repo: https://github.com/PyCQA/bandit
rev: 1.9.2
hooks:
- id: bandit
args: ["-r", "-lll"]
exclude: ".*fixtures"
# Conflicts with Black.
# - repo: https://github.com/pycqa/isort
# rev: 5.12.0
# hooks:
# - id: isort
# args: ["--line-length", "120"]
# - id: tests
# name: tests
# entry: bash -c "pip install . && pytest -v -xxx"
# description: Tests expected output of all scripts
# language: system
# types: [python]
# TODO: Enable this on the knp/pyframework
# - repo: https://github.com/regebro/pyroma
# rev: "4.1"
# hooks:
# - id: pyroma
# # Must be specified because of the default value in pyroma
# always_run: false
# args: ["knp"]
# files: |
# (?x)^(
# README.md|
# pyproject.toml|
# pylint/__init__.py|
# pylint/__pkginfo__.py|
# setup.cfg
# )$
#
# Markdown
#
# Written on Ruby, but we don't want to install gem.
# - repo: https://github.com/markdownlint/markdownlint
# rev: "v0.12.0"
# hooks:
# - id: markdownlint
- repo: https://github.com/executablebooks/mdformat
rev: "1.0.0"
hooks:
- id: mdformat