Skip to content

Latest commit

 

History

History
119 lines (89 loc) · 3.12 KB

File metadata and controls

119 lines (89 loc) · 3.12 KB

Pre-commit Setup for CometX

This document describes the pre-commit setup for the CometX repository.

What's Included

The pre-commit configuration includes the following hooks:

Automatic Hooks (run on every commit)

  • Black: Code formatting (88 character line length)
  • isort: Import sorting (compatible with Black)
  • flake8: Linting (with Black-compatible settings)
  • pre-commit hooks: Various general checks:
    • Merge conflict detection
    • YAML/JSON validation
    • Large file detection
    • Case conflict detection
    • Docstring placement
    • AST validation
    • Debug statement detection
    • End-of-file fixing
    • Trailing whitespace removal
    • TOML validation
    • VCS permalink checking
    • Mixed line ending detection
    • Requirements.txt sorting

Manual Hooks (run only when explicitly called)

  • mypy: Type checking (basic mode)
  • pydocstyle: Documentation style checking

Setup Instructions

  1. Install development dependencies:

    pip install -r requirements-dev.txt
  2. Install pre-commit hooks:

    pre-commit install
  3. (Optional) Run the setup script:

    ./setup-pre-commit.sh

Usage

Automatic Checks

The automatic hooks will run every time you commit. If any fail, the commit will be blocked until the issues are fixed.

Manual Checks

To run the manual hooks:

# Run all manual hooks
pre-commit run --all-files --hook-stage manual

# Run specific manual hooks
pre-commit run mypy --all-files
pre-commit run pydocstyle --all-files

Running Specific Hooks

# Run all hooks on all files
pre-commit run --all-files

# Run specific hooks
pre-commit run black --all-files
pre-commit run flake8 --all-files
pre-commit run isort --all-files

Configuration Files

  • .pre-commit-config.yaml: Main pre-commit configuration
  • .flake8: Flake8 linting configuration
  • pyproject.toml: Black, isort, and mypy configuration

Current Status

Working Hooks:

  • Black (code formatting)
  • isort (import sorting)
  • flake8 (linting)
  • All pre-commit general hooks

⚠️ Manual Hooks:

  • mypy (type checking) - set to manual due to existing type issues
  • pydocstyle (documentation) - set to manual due to extensive docstring issues

Known Issues

  1. Line Length Violations: Some files exceed the 88-character line limit
  2. Type Annotations: Some files have syntax errors in type annotations
  3. Documentation: Many functions and classes lack proper docstrings
  4. Code Quality: Focus on formatting, imports, and linting

Next Steps

To improve the code quality:

  1. Fix line length violations: Run pre-commit run black --all-files to auto-format
  2. Fix type annotations: Address mypy errors in cometx/framework/comet/download_manager.py
  3. Add docstrings: Gradually add proper documentation to functions and classes
  4. Improve code quality: Focus on formatting, imports, and linting issues

Disabling Hooks

If you need to bypass pre-commit hooks temporarily:

git commit --no-verify -m "Your commit message"

Note: This should only be used in emergencies, not as a regular practice.