pygraphistry icon indicating copy to clipboard operation
pygraphistry copied to clipboard

Setup pre-commit hooks for automatic linting and type checking

Open lmeyerov opened this issue 2 months ago • 0 comments

Background

Issue #801 recommended setting up pre-commit hooks to catch issues before they reach CI/CD.

Proposed Setup

Install pre-commit framework and configure hooks for:

  1. Ruff - Fast Python linting (already in use)
  2. MyPy - Type checking (already in use)
  3. Trailing whitespace - Clean up whitespace
  4. End-of-file fixer - Ensure newline at EOF
  5. YAML/JSON validation - Catch syntax errors

Example .pre-commit-config.yaml

repos:
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.1.0  # Use latest version
    hooks:
      - id: ruff
        args: [--fix]
      - id: ruff-format

  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.7.0  # Use latest version
    hooks:
      - id: mypy
        additional_dependencies: [types-all]

  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.5.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-json
      - id: check-added-large-files

Benefits

  • Catches lint/type errors before commit
  • Faster feedback loop than waiting for CI
  • Reduces CI failures from trivial issues
  • Consistent code quality across all commits

Installation

pip install pre-commit
pre-commit install

Priority

Long-term improvement (not urgent)

Related Issues

  • #801 - Original issue recommending this improvement

🤖 Generated with Claude Code

lmeyerov avatar Oct 19 '25 02:10 lmeyerov