A few improvements to validation.

This commit is contained in:
Storm Dragon
2025-07-24 14:05:51 -04:00
parent 8c233e0385
commit 94a1acbaca
4 changed files with 404 additions and 0 deletions

View File

@ -125,6 +125,43 @@ else
VALIDATION_FAILED=1
fi
# 2a2. PEP8/flake8 Validation (for staged Python files only)
echo -e "\n${YELLOW} 2a2. Checking PEP8 compliance...${NC}"
if command -v flake8 >/dev/null 2>&1 && [ -n "$STAGED_PYTHON_FILES" ]; then
PEP8_ISSUES=0
# Check staged Python files with flake8
# Focus on critical issues, ignore cosmetic ones for pre-commit
FLAKE8_SELECT="E9,F63,F7,F82" # Critical syntax/import errors only
FLAKE8_IGNORE="E501,W503,E203" # Ignore line length and some formatting
for file in $STAGED_PYTHON_FILES; do
if [ -f "$file" ]; then
flake8_output=$(flake8 --select="$FLAKE8_SELECT" --ignore="$FLAKE8_IGNORE" "$file" 2>/dev/null || true)
if [ -n "$flake8_output" ]; then
if [ $PEP8_ISSUES -eq 0 ]; then
echo -e "${RED} ✗ Critical PEP8 issues found:${NC}"
fi
echo -e "${RED} $file:${NC}"
echo "$flake8_output" | sed 's/^/ /'
PEP8_ISSUES=1
fi
fi
done
if [ $PEP8_ISSUES -eq 0 ]; then
echo -e "${GREEN} ✓ No critical PEP8 issues in staged files${NC}"
else
echo -e "${RED} ✗ Critical PEP8 issues found${NC}"
echo -e "${YELLOW} Run: flake8 --select=E9,F63,F7,F82 <file> for details${NC}"
VALIDATION_FAILED=1
fi
elif [ -n "$STAGED_PYTHON_FILES" ]; then
echo -e "${YELLOW} ⚠ flake8 not available (install with: pip install flake8)${NC}"
else
echo -e "${GREEN} ✓ No Python files to check${NC}"
fi
# 2b. Check for common issues in modified files
echo -e "\n${YELLOW} 2b. Checking modified files for common issues...${NC}"