-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathfind_type_ignores.sh
More file actions
executable file
·113 lines (95 loc) · 3.24 KB
/
Copy pathfind_type_ignores.sh
File metadata and controls
executable file
·113 lines (95 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
# Find all type ignore comments in the codebase
# Excludes: tests, examples, tmp directories (optional)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Parse arguments
EXCLUDE_TESTS=false
EXCLUDE_EXAMPLES=false
EXCLUDE_TMP=true
while [[ $# -gt 0 ]]; do
case $1 in
--exclude-tests)
EXCLUDE_TESTS=true
shift
;;
--exclude-examples)
EXCLUDE_EXAMPLES=true
shift
;;
--include-tmp)
EXCLUDE_TMP=false
shift
;;
--all)
EXCLUDE_TESTS=false
EXCLUDE_EXAMPLES=false
EXCLUDE_TMP=false
shift
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [--exclude-tests] [--exclude-examples] [--include-tmp] [--all]"
exit 1
;;
esac
done
# Build grep exclude patterns (always exclude .venv, .git, etc.)
EXCLUDE_PATTERN="--exclude-dir=.venv --exclude-dir=.git --exclude-dir=__pycache__ --exclude-dir=node_modules --exclude-dir=.pytest_cache --exclude-dir=type-check-except"
if [ "$EXCLUDE_TESTS" = true ]; then
EXCLUDE_PATTERN="$EXCLUDE_PATTERN --exclude-dir=tests"
fi
if [ "$EXCLUDE_EXAMPLES" = true ]; then
EXCLUDE_PATTERN="$EXCLUDE_PATTERN --exclude-dir=examples"
fi
if [ "$EXCLUDE_TMP" = true ]; then
EXCLUDE_PATTERN="$EXCLUDE_PATTERN --exclude-dir=tmp"
fi
echo -e "${BLUE}Searching for type ignore comments...${NC}"
echo ""
# Search patterns
PATTERNS=(
"type:\s*ignore"
"noqa"
"pyright:\s*ignore"
"mypy:\s*ignore"
"@(typing\.)?no_type_check"
)
# Count total
TOTAL=0
for pattern in "${PATTERNS[@]}"; do
COUNT=$(grep -r -n --include="*.py" $EXCLUDE_PATTERN -E "#\s*$pattern" "$SCRIPT_DIR" 2>/dev/null | wc -l)
if [ $COUNT -gt 0 ]; then
TOTAL=$((TOTAL + COUNT))
fi
done
if [ $TOTAL -eq 0 ]; then
echo -e "${GREEN}✅ No type ignore comments found!${NC}"
exit 0
fi
echo -e "${YELLOW}Found $TOTAL type ignore comment(s):${NC}"
echo ""
# Show detailed results
echo -e "${BLUE}# type: ignore${NC}"
grep -r -n --include="*.py" $EXCLUDE_PATTERN -E "#\s*type:\s*ignore" "$SCRIPT_DIR" 2>/dev/null || echo " (none)"
echo ""
echo -e "${BLUE}# noqa${NC}"
grep -r -n --include="*.py" $EXCLUDE_PATTERN -E "#\s*noqa" "$SCRIPT_DIR" 2>/dev/null || echo " (none)"
echo ""
echo -e "${BLUE}# pyright: ignore${NC}"
grep -r -n --include="*.py" $EXCLUDE_PATTERN -E "#\s*pyright:\s*ignore" "$SCRIPT_DIR" 2>/dev/null || echo " (none)"
echo ""
echo -e "${BLUE}# mypy: ignore${NC}"
grep -r -n --include="*.py" $EXCLUDE_PATTERN -E "#\s*mypy:\s*ignore" "$SCRIPT_DIR" 2>/dev/null || echo " (none)"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "Total: ${RED}$TOTAL${NC} type ignore comment(s)"
if [ "$EXCLUDE_TESTS" = false ] && [ "$EXCLUDE_EXAMPLES" = false ]; then
echo ""
echo "💡 Tip: Use --exclude-tests and --exclude-examples to see only production code issues"
fi