.pre-commit-config.yamlโข4.18 kB
# Pre-commit hooks for code quality and consistency
# Install: pip install pre-commit && pre-commit install
# Run manually: pre-commit run --all-files
# Update hooks: pre-commit autoupdate
default_language_version:
python: python3.11
repos:
# General file checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
args: ['--maxkb=1000']
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-xml
- id: check-yaml
args: ['--unsafe']
- id: debug-statements
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: fix-encoding-pragma
args: ['--remove']
- id: mixed-line-ending
args: ['--fix=lf']
- id: name-tests-test
args: ['--pytest-test-first']
- id: trailing-whitespace
# Python code formatting with Black
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
language_version: python3.11
args: ['--config', 'pyproject.toml']
# Python linting with Ruff (fast!)
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.4
hooks:
- id: ruff
args: ['--fix', '--exit-non-zero-on-fix']
- id: ruff-format
# Type checking with MyPy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
additional_dependencies:
- pandas-stubs>=2.2.3
- types-aiofiles>=24.1.0
- types-tabulate>=0.9.0
- types-pytz>=2024.2
args: ['--config-file', 'pyproject.toml']
pass_filenames: false
args: ['src/']
# Security checks with Bandit
- repo: https://github.com/PyCQA/bandit
rev: 1.7.10
hooks:
- id: bandit
args: ['-r', 'src/', '-ll', '-x', 'tests/']
# Markdown formatting
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.43.0
hooks:
- id: markdownlint
args: ['--fix']
# YAML formatting
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
types_or: [yaml, json]
exclude: ^(.*\.min\.(js|css)|package-lock\.json)$
# Check for outdated Python syntax
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
hooks:
- id: pyupgrade
args: ['--py38-plus']
# Remove unused imports
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.1
hooks:
- id: autoflake
args:
- --in-place
- --remove-all-unused-imports
- --remove-unused-variables
- --remove-duplicate-keys
- --ignore-init-module-imports
# Sort imports
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
args: ['--profile', 'black', '--line-length', '100']
# Docstring formatting
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
hooks:
- id: docformatter
args:
- --in-place
- --wrap-summaries=100
- --wrap-descriptions=100
# Check for common security issues
- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets
args: ['--baseline', '.secrets.baseline']
# License headers
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: insert-license
files: \.py$
args:
- --license-filepath
- LICENSE
- --comment-style
- "#"
exclude: ^(tests/|examples/|__pycache__/)
ci:
autofix_prs: true
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit hooks
for more information, see https://pre-commit.ci
autoupdate_schedule: weekly
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
skip: [mypy, bandit] # These can be slow in CI