{
"event": "PreToolUse",
"tool_name": "Read",
"tool_input": {
"file_path": "\/opt\/scripts\/python-check.sh"
}
}
{
"tool_response": {
"type": "text",
"file": {
"filePath": "\/opt\/scripts\/python-check.sh",
"content": "#!\/bin\/bash\n# Python Quality Check Script\n# Verwendet: Ruff (Linting + Formatting) + mypy (Type Checking)\n\nPIPELINE_DIR=\"${1:-\/opt\/scripts\/pipeline}\"\nVENV_BIN=\"$PIPELINE_DIR\/venv\/bin\"\nRUFF=\"$VENV_BIN\/ruff\"\nMYPY=\"$VENV_BIN\/mypy\"\nCONFIG=\"$PIPELINE_DIR\/ruff.toml\"\n\n# Colors\nRED='\\033[0;31m'\nGREEN='\\033[0;32m'\nYELLOW='\\033[1;33m'\nNC='\\033[0m'\n\necho \"=== Python Quality Check: $(date) ===\"\necho \"Directory: $PIPELINE_DIR\"\necho \"\"\n\nERRORS=0\n\n# Check if tools exist\nif [[ ! -f \"$RUFF\" ]]; then\n echo -e \"${RED}Error: Ruff not found at $RUFF${NC}\"\n exit 1\nfi\n\nif [[ ! -f \"$MYPY\" ]]; then\n echo -e \"${RED}Error: mypy not found at $MYPY${NC}\"\n exit 1\nfi\n\n# 1. Ruff Linting\necho -e \"${YELLOW}[1\/3] Ruff - Linting${NC}\"\nif $RUFF check \"$PIPELINE_DIR\" --config \"$CONFIG\" --exclude \"venv\" 2>&1; then\n echo -e \"${GREEN}✓ Ruff: No linting errors${NC}\"\nelse\n echo -e \"${RED}✗ Ruff: Linting errors found${NC}\"\n ERRORS=$((ERRORS + 1))\nfi\necho \"\"\n\n# 2. Ruff Formatting Check\necho -e \"${YELLOW}[2\/3] Ruff - Format Check${NC}\"\nif $RUFF format \"$PIPELINE_DIR\" --check --config \"$CONFIG\" --exclude \"venv\" 2>&1; then\n echo -e \"${GREEN}✓ Ruff: Formatting OK${NC}\"\nelse\n echo -e \"${RED}✗ Ruff: Formatting issues found (run with --fix to auto-format)${NC}\"\n ERRORS=$((ERRORS + 1))\nfi\necho \"\"\n\n# 3. mypy Type Checking (optional, non-blocking for now)\necho -e \"${YELLOW}[3\/3] mypy - Type Checking${NC}\"\nif $MYPY \"$PIPELINE_DIR\" --exclude \"venv\" --ignore-missing-imports --no-error-summary 2>&1 | head -20; then\n echo -e \"${GREEN}✓ mypy: Type check complete${NC}\"\nelse\n echo -e \"${YELLOW}⚠ mypy: Type hints missing (non-blocking)${NC}\"\nfi\necho \"\"\n\n# Summary\necho \"=== Summary ===\"\nif [[ $ERRORS -eq 0 ]]; then\n echo -e \"${GREEN}All checks passed!${NC}\"\n exit 0\nelse\n echo -e \"${RED}$ERRORS check(s) failed${NC}\"\n exit 1\nfi\n",
"numLines": 72,
"startLine": 1,
"totalLines": 72
}
}
}