Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[flake8]
# Flake8 configuration for ComfyUI Motion Transfer

# Maximum line length (matching Black)
max-line-length = 100

# Ignore specific error codes
# E203: Whitespace before ':' (conflicts with Black)
# E501: Line too long (handled by Black)
# W503: Line break before binary operator (conflicts with Black)
# E402: Module level import not at top of file (needed for some imports)
extend-ignore = E203, E501, W503, E402

# Exclude directories
exclude =
.git,
__pycache__,
.venv,
venv,
*.egg-info,
dist,
build,
raft_vendor,
searaft_vendor,
motion_transfer_nodes_backup.py,
.pytest_cache,
.mypy_cache

# Per-file ignores
per-file-ignores =
__init__.py:F401,F403
tests/*:F401,F841

# Maximum complexity (cyclomatic complexity)
max-complexity = 15

# Show source code for each error
show-source = True

# Show pep8 error code
show-pep8 = True

# Count errors
count = True

# Print total number of errors
statistics = True
32 changes: 32 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Pre-commit Checks

on:
push:
branches: [ main, master, claude/* ]
pull_request:
branches: [ main, master ]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pre-commit

- name: Run pre-commit hooks
run: pre-commit run --all-files --show-diff-on-failure

- name: Lint summary
if: failure()
run: |
echo "❌ Pre-commit checks failed. Please run 'pre-commit run --all-files' locally and fix issues."
exit 1
107 changes: 107 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Pre-commit hooks for ComfyUI Motion Transfer
# Install: pip install pre-commit
# Setup: pre-commit install
# Run manually: pre-commit run --all-files

default_language_version:
python: python3

repos:
# Code formatting with Black
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
name: Format code with Black
language_version: python3
args: ['--line-length=100']
exclude: ^(raft_vendor/|searaft_vendor/|motion_transfer_nodes_backup\.py)

# Import sorting with isort
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
name: Sort imports with isort
args: ['--profile=black', '--line-length=100']
exclude: ^(raft_vendor/|searaft_vendor/|motion_transfer_nodes_backup\.py)

# Linting with flake8
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
name: Lint with flake8
args: [
'--max-line-length=100',
'--extend-ignore=E203,E501,W503,E402', # Black compatibility + allow imports not at top
'--exclude=raft_vendor,searaft_vendor,motion_transfer_nodes_backup.py',
'--per-file-ignores=__init__.py:F401,F403' # Allow unused imports in __init__.py
]

# Type checking with mypy (optional - can be strict)
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.8.0
# hooks:
# - id: mypy
# name: Type check with mypy
# additional_dependencies: [types-all]
# args: ['--ignore-missing-imports', '--no-strict-optional']
# exclude: ^(raft_vendor/|searaft_vendor/|tests/|motion_transfer_nodes_backup\.py)

# General file quality checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
name: Trim trailing whitespace
exclude: ^(raft_vendor/|searaft_vendor/)
- id: end-of-file-fixer
name: Fix end of files
exclude: ^(raft_vendor/|searaft_vendor/|\.md$)
- id: check-yaml
name: Check YAML syntax
- id: check-json
name: Check JSON syntax
- id: check-added-large-files
name: Check for large files
args: ['--maxkb=5000']
- id: check-merge-conflict
name: Check for merge conflicts
- id: debug-statements
name: Check for debug statements
exclude: ^(raft_vendor/|searaft_vendor/|tests/)
- id: mixed-line-ending
name: Fix mixed line endings
args: ['--fix=lf']
exclude: ^(raft_vendor/|searaft_vendor/)

# Security checks with bandit
- repo: https://github.com/PyCQA/bandit
rev: 1.7.6
hooks:
- id: bandit
name: Security check with bandit
args: ['-ll', '--recursive', '--exclude=raft_vendor,searaft_vendor,tests']
exclude: ^(raft_vendor/|searaft_vendor/|tests/)

# Markdown linting (optional)
- repo: https://github.com/markdownlint/markdownlint
rev: v0.12.0
hooks:
- id: markdownlint
name: Lint Markdown files
args: ['--rules', '~MD013,~MD033,~MD041'] # Ignore line length, HTML, first line

# CI mode - fail fast
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit hooks

for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: monthly
skip: []
submodules: false
Loading
Loading