fix(lint): auto-fix ruff violations and tune lint rules
- Auto-fixed 4,496 lint issues (import sorting, modern syntax, etc.) - Added ignore rules for patterns intentional in this codebase: E402 (late imports), E712 (SQLAlchemy filters), B904 (raise from), SIM108/SIM105/SIM117 (readability preferences) - Added per-file ignores for tests and scripts - Excluded broken scripts/rename_terminology.py (has curly quotes) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -20,8 +20,8 @@ import json
|
||||
import re
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
from pathlib import Path
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -136,7 +136,7 @@ class ModuleDependencyAnalyzer:
|
||||
in_type_checking = False
|
||||
type_checking_indent = 0
|
||||
|
||||
for i, line in enumerate(lines, 1):
|
||||
for _i, line in enumerate(lines, 1):
|
||||
stripped = line.strip()
|
||||
if stripped.startswith("#") or not stripped:
|
||||
continue
|
||||
@@ -167,7 +167,7 @@ class ModuleDependencyAnalyzer:
|
||||
|
||||
# Look for import statements
|
||||
import_match = re.match(
|
||||
r'^\s*(?:from\s+(app\.modules\.(\w+))|import\s+(app\.modules\.(\w+)))',
|
||||
r"^\s*(?:from\s+(app\.modules\.(\w+))|import\s+(app\.modules\.(\w+)))",
|
||||
line
|
||||
)
|
||||
|
||||
@@ -291,13 +291,13 @@ def format_mermaid(analyzer: ModuleDependencyAnalyzer) -> str:
|
||||
lines = []
|
||||
lines.append("```mermaid")
|
||||
lines.append("flowchart TD")
|
||||
lines.append(" subgraph core[\"Core Modules\"]")
|
||||
lines.append(' subgraph core["Core Modules"]')
|
||||
for module in sorted(analyzer.CORE_MODULES):
|
||||
if module in analyzer.modules:
|
||||
lines.append(f" {module}[{module}]")
|
||||
lines.append(" end")
|
||||
lines.append("")
|
||||
lines.append(" subgraph optional[\"Optional Modules\"]")
|
||||
lines.append(' subgraph optional["Optional Modules"]')
|
||||
for module in sorted(analyzer.OPTIONAL_MODULES):
|
||||
if module in analyzer.modules:
|
||||
lines.append(f" {module}[{module}]")
|
||||
@@ -306,7 +306,7 @@ def format_mermaid(analyzer: ModuleDependencyAnalyzer) -> str:
|
||||
|
||||
# Add edges
|
||||
for source, deps in analyzer.dependencies.items():
|
||||
for target, dep in deps.items():
|
||||
for target, _dep in deps.items():
|
||||
# Style violations differently
|
||||
source_is_core = source in analyzer.CORE_MODULES
|
||||
target_is_optional = target in analyzer.OPTIONAL_MODULES
|
||||
@@ -323,43 +323,43 @@ def format_dot(analyzer: ModuleDependencyAnalyzer) -> str:
|
||||
"""Format output as GraphViz DOT."""
|
||||
lines = []
|
||||
lines.append("digraph ModuleDependencies {")
|
||||
lines.append(' rankdir=LR;')
|
||||
lines.append(' node [shape=box];')
|
||||
lines.append('')
|
||||
lines.append(" rankdir=LR;")
|
||||
lines.append(" node [shape=box];")
|
||||
lines.append("")
|
||||
|
||||
# Core modules cluster
|
||||
lines.append(' subgraph cluster_core {')
|
||||
lines.append(" subgraph cluster_core {")
|
||||
lines.append(' label="Core Modules";')
|
||||
lines.append(' style=filled;')
|
||||
lines.append(' color=lightblue;')
|
||||
lines.append(" style=filled;")
|
||||
lines.append(" color=lightblue;")
|
||||
for module in sorted(analyzer.CORE_MODULES):
|
||||
if module in analyzer.modules:
|
||||
lines.append(f' {module};')
|
||||
lines.append(' }')
|
||||
lines.append('')
|
||||
lines.append(f" {module};")
|
||||
lines.append(" }")
|
||||
lines.append("")
|
||||
|
||||
# Optional modules cluster
|
||||
lines.append(' subgraph cluster_optional {')
|
||||
lines.append(" subgraph cluster_optional {")
|
||||
lines.append(' label="Optional Modules";')
|
||||
lines.append(' style=filled;')
|
||||
lines.append(' color=lightyellow;')
|
||||
lines.append(" style=filled;")
|
||||
lines.append(" color=lightyellow;")
|
||||
for module in sorted(analyzer.OPTIONAL_MODULES):
|
||||
if module in analyzer.modules:
|
||||
lines.append(f' {module};')
|
||||
lines.append(' }')
|
||||
lines.append('')
|
||||
lines.append(f" {module};")
|
||||
lines.append(" }")
|
||||
lines.append("")
|
||||
|
||||
# Edges
|
||||
for source, deps in analyzer.dependencies.items():
|
||||
for target, dep in deps.items():
|
||||
for target, _dep in deps.items():
|
||||
source_is_core = source in analyzer.CORE_MODULES
|
||||
target_is_optional = target in analyzer.OPTIONAL_MODULES
|
||||
if source_is_core and target_is_optional:
|
||||
lines.append(f' {source} -> {target} [color=red, style=dashed, label="violation"];')
|
||||
else:
|
||||
lines.append(f' {source} -> {target};')
|
||||
lines.append(f" {source} -> {target};")
|
||||
|
||||
lines.append('}')
|
||||
lines.append("}")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user