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:
@@ -10,18 +10,18 @@ Services:
|
||||
"""
|
||||
|
||||
from app.modules.dev_tools.services.code_quality_service import (
|
||||
code_quality_service,
|
||||
CodeQualityService,
|
||||
VALIDATOR_ARCHITECTURE,
|
||||
VALIDATOR_SECURITY,
|
||||
VALIDATOR_PERFORMANCE,
|
||||
VALID_VALIDATOR_TYPES,
|
||||
VALIDATOR_SCRIPTS,
|
||||
VALIDATOR_ARCHITECTURE,
|
||||
VALIDATOR_NAMES,
|
||||
VALIDATOR_PERFORMANCE,
|
||||
VALIDATOR_SCRIPTS,
|
||||
VALIDATOR_SECURITY,
|
||||
CodeQualityService,
|
||||
code_quality_service,
|
||||
)
|
||||
from app.modules.dev_tools.services.test_runner_service import (
|
||||
test_runner_service,
|
||||
TestRunnerService,
|
||||
test_runner_service,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
|
||||
@@ -7,22 +7,22 @@ Supports multiple validator types: architecture, security, performance
|
||||
import json
|
||||
import logging
|
||||
import subprocess
|
||||
from datetime import datetime, UTC
|
||||
from datetime import UTC, datetime
|
||||
|
||||
from sqlalchemy import desc, func
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.modules.monitoring.exceptions import (
|
||||
ScanParseException,
|
||||
ScanTimeoutException,
|
||||
ViolationNotFoundException,
|
||||
)
|
||||
from app.modules.dev_tools.models import (
|
||||
ArchitectureScan,
|
||||
ArchitectureViolation,
|
||||
ViolationAssignment,
|
||||
ViolationComment,
|
||||
)
|
||||
from app.modules.monitoring.exceptions import (
|
||||
ScanParseException,
|
||||
ScanTimeoutException,
|
||||
ViolationNotFoundException,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -565,7 +565,7 @@ class CodeQualityService:
|
||||
.group_by(ArchitectureViolation.status)
|
||||
.all()
|
||||
)
|
||||
status_dict = {status: count for status, count in status_counts}
|
||||
status_dict = dict(status_counts)
|
||||
|
||||
# Get violations by severity
|
||||
severity_counts = (
|
||||
@@ -576,7 +576,7 @@ class CodeQualityService:
|
||||
.group_by(ArchitectureViolation.severity)
|
||||
.all()
|
||||
)
|
||||
by_severity = {sev: count for sev, count in severity_counts}
|
||||
by_severity = dict(severity_counts)
|
||||
|
||||
# Get violations by rule
|
||||
rule_counts = (
|
||||
@@ -587,10 +587,7 @@ class CodeQualityService:
|
||||
.group_by(ArchitectureViolation.rule_id)
|
||||
.all()
|
||||
)
|
||||
by_rule = {
|
||||
rule: count
|
||||
for rule, count in sorted(rule_counts, key=lambda x: x[1], reverse=True)[:10]
|
||||
}
|
||||
by_rule = dict(sorted(rule_counts, key=lambda x: x[1], reverse=True)[:10])
|
||||
|
||||
# Get top violating files
|
||||
file_counts = (
|
||||
@@ -667,7 +664,7 @@ class CodeQualityService:
|
||||
.group_by(ArchitectureViolation.status)
|
||||
.all()
|
||||
)
|
||||
status_dict = {status: count for status, count in status_counts}
|
||||
status_dict = dict(status_counts)
|
||||
|
||||
# Get violations by severity
|
||||
severity_counts = (
|
||||
@@ -678,7 +675,7 @@ class CodeQualityService:
|
||||
.group_by(ArchitectureViolation.severity)
|
||||
.all()
|
||||
)
|
||||
by_severity = {sev: count for sev, count in severity_counts}
|
||||
by_severity = dict(severity_counts)
|
||||
|
||||
# Get violations by rule (across all validators)
|
||||
rule_counts = (
|
||||
@@ -689,10 +686,7 @@ class CodeQualityService:
|
||||
.group_by(ArchitectureViolation.rule_id)
|
||||
.all()
|
||||
)
|
||||
by_rule = {
|
||||
rule: count
|
||||
for rule, count in sorted(rule_counts, key=lambda x: x[1], reverse=True)[:10]
|
||||
}
|
||||
by_rule = dict(sorted(rule_counts, key=lambda x: x[1], reverse=True)[:10])
|
||||
|
||||
# Get top violating files
|
||||
file_counts = (
|
||||
@@ -761,10 +755,7 @@ class CodeQualityService:
|
||||
|
||||
for v in violations:
|
||||
path_parts = v.file_path.split("/")
|
||||
if len(path_parts) >= 2:
|
||||
module = "/".join(path_parts[:2])
|
||||
else:
|
||||
module = path_parts[0]
|
||||
module = "/".join(path_parts[:2]) if len(path_parts) >= 2 else path_parts[0]
|
||||
by_module[module] = by_module.get(module, 0) + 1
|
||||
|
||||
return dict(sorted(by_module.items(), key=lambda x: x[1], reverse=True)[:10])
|
||||
|
||||
@@ -3,6 +3,7 @@ Test Runner Service
|
||||
Service for running pytest and storing results
|
||||
"""
|
||||
|
||||
import contextlib
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
@@ -123,10 +124,8 @@ class TestRunnerService:
|
||||
self._parse_pytest_output(test_run, result.stdout, result.stderr)
|
||||
finally:
|
||||
# Clean up temp file
|
||||
try:
|
||||
with contextlib.suppress(Exception):
|
||||
Path(json_report_path).unlink()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Set final status
|
||||
if test_run.failed > 0 or test_run.errors > 0:
|
||||
@@ -428,7 +427,7 @@ class TestRunnerService:
|
||||
) as f:
|
||||
json_report_path = f.name
|
||||
|
||||
result = subprocess.run(
|
||||
subprocess.run(
|
||||
[
|
||||
"python",
|
||||
"-m",
|
||||
|
||||
Reference in New Issue
Block a user