mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-10 20:27:15 +01:00
Standalone utils subproject (pyproject, pre-commit, CI, install.sh, README with the library API). It no longer imports leetcode_guard: guard_bridge resolves the three read-only calls on demand. Q5: SQL problems skip req: and ask for an OUTPUT SHAPE (columns, rows, grouping) before code; algorithm problems keep req:. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWYGW5NZL5uVpnqmNKo
158 lines
5.3 KiB
YAML
158 lines
5.3 KiB
YAML
# Pre-commit Configuration for leetcode_coach
|
|
# Install: pre-commit install && pre-commit install --hook-type pre-push
|
|
# Run: pre-commit run --all-files
|
|
# Update: pre-commit autoupdate
|
|
|
|
# NOTE: this subproject lives inside the ~/src/utils monorepo, whose git root is
|
|
# one level up. pre-commit always runs hooks from the git root, so every path
|
|
# below is written relative to THAT, not to this directory, and the top-level
|
|
# `files` key keeps these hooks off the sibling subprojects. CI invokes this
|
|
# config exactly the same way:
|
|
# pre-commit run --config leetcode_coach/.pre-commit-config.yaml --all-files
|
|
files: ^leetcode_coach/
|
|
|
|
default_language_version:
|
|
python: python3
|
|
default_stages: [pre-commit]
|
|
fail_fast: false
|
|
|
|
repos:
|
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
rev: v4.6.0
|
|
hooks:
|
|
- id: trailing-whitespace
|
|
args: [--markdown-linebreak-ext=md]
|
|
- id: end-of-file-fixer
|
|
- id: check-yaml
|
|
- id: check-json
|
|
- id: check-toml
|
|
- id: check-added-large-files
|
|
args: [--maxkb=2000]
|
|
- id: check-merge-conflict
|
|
- id: detect-private-key
|
|
- id: debug-statements
|
|
- id: name-tests-test
|
|
args: [--pytest-test-first]
|
|
# Shared, non-test helpers (fixtures, fakes) imported by the real test
|
|
# modules: deliberately not collected, hence the leading underscore.
|
|
exclude: ^leetcode_coach/leetcode_coach/tests/_[a-z][a-z_]*\.py$
|
|
- id: check-ast
|
|
- id: mixed-line-ending
|
|
args: [--fix=lf]
|
|
- id: requirements-txt-fixer
|
|
|
|
- repo: local
|
|
hooks:
|
|
- id: file-length-cap
|
|
name: file length <= 250 lines
|
|
entry: bash scripts/check_file_length.sh
|
|
language: system
|
|
pass_filenames: true
|
|
- id: subproject-scope
|
|
name: subproject scope regex still matches
|
|
entry: scripts/check_subproject_scope.sh leetcode_coach
|
|
language: script
|
|
# always_run so the top-level `files` filter cannot skip the one hook
|
|
# whose job is to notice that filter has stopped matching anything.
|
|
always_run: true
|
|
pass_filenames: false
|
|
- id: no-noqa
|
|
name: Block noqa comments
|
|
entry: '(?i)#\s*(noqa|type:\s*ignore)'
|
|
language: pygrep
|
|
types: [python]
|
|
- id: no-ruff-noqa
|
|
name: Block ruff noqa file-level comments
|
|
entry: '(?i)#\s*ruff:\s*noqa'
|
|
language: pygrep
|
|
types: [python]
|
|
|
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
rev: v0.17.2
|
|
hooks:
|
|
- id: ruff
|
|
args: [--fix, --unsafe-fixes, --exit-non-zero-on-fix, --show-fixes]
|
|
types_or: [python, pyi]
|
|
- id: ruff-format
|
|
types_or: [python, pyi]
|
|
|
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
rev: v1.13.0
|
|
hooks:
|
|
- id: mypy
|
|
# Isolated env: the requests stubs must be declared here too.
|
|
additional_dependencies:
|
|
- types-requests
|
|
args:
|
|
- --ignore-missing-imports
|
|
- --no-error-summary
|
|
- --disable-error-code=no-untyped-def
|
|
- --disable-error-code=no-untyped-call
|
|
- --disable-error-code=var-annotated
|
|
- --disable-error-code=no-any-unimported
|
|
- --disable-error-code=type-arg
|
|
- --disable-error-code=no-any-return
|
|
- --disable-error-code=misc
|
|
- --disable-error-code=unused-ignore
|
|
- --disable-error-code=unreachable
|
|
- --disable-error-code=assignment
|
|
- --disable-error-code=no-redef
|
|
- --disable-error-code=attr-defined
|
|
- --disable-error-code=arg-type
|
|
- --disable-error-code=union-attr
|
|
- --disable-error-code=call-overload
|
|
- --disable-error-code=return-value
|
|
- --disable-error-code=redundant-cast
|
|
- --disable-error-code=empty-body
|
|
- --disable-error-code=list-item
|
|
|
|
- repo: https://github.com/pylint-dev/pylint
|
|
rev: v4.0.8
|
|
hooks:
|
|
- id: pylint
|
|
args:
|
|
- --rcfile=leetcode_coach/pyproject.toml
|
|
- --fail-under=8.0
|
|
- --jobs=4
|
|
- leetcode_coach/leetcode_coach
|
|
# Whole package, never the staged subset: a score over an arbitrary
|
|
# handful of files is an arbitrary number. Kept in step with
|
|
# requirements.txt.
|
|
pass_filenames: false
|
|
additional_dependencies:
|
|
- pytest
|
|
- requests
|
|
- genanki
|
|
- crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.9.2#subdirectory=crdt-sync
|
|
|
|
- repo: https://github.com/PyCQA/bandit
|
|
rev: 1.9.4
|
|
hooks:
|
|
- id: bandit
|
|
args:
|
|
- -c
|
|
- leetcode_coach/pyproject.toml
|
|
- --severity-level=high
|
|
- --confidence-level=medium
|
|
- --skip=B113
|
|
additional_dependencies: ["bandit[toml]"]
|
|
exclude: ^(leetcode_coach/leetcode_coach/tests/|.*test.*\.py$)
|
|
|
|
- repo: local
|
|
hooks:
|
|
- id: pytest-coverage
|
|
name: pytest with coverage enforcement
|
|
entry: scripts/run_subproject_tests.sh leetcode_coach
|
|
language: script
|
|
types: [python]
|
|
pass_filenames: false
|
|
require_serial: true
|
|
stages: [pre-push]
|
|
|
|
- repo: https://github.com/codespell-project/codespell
|
|
rev: v2.3.0
|
|
hooks:
|
|
- id: codespell
|
|
args:
|
|
- --skip=*.json,*.lock,.git,__pycache__,.venv
|