Skip to content

Commit 13af4ff

Browse files
authored
Merge pull request #112 from QWED-AI/rahul/unused-import-cleanup-3
Clean up unused imports and broad except handlers
2 parents 6f5d619 + 730262c commit 13af4ff

25 files changed

Lines changed: 300 additions & 67 deletions

action_entrypoint.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import os
1111
import sys
1212
import json
13-
import glob
1413
from pathlib import Path
1514

1615
try:

qwed/guards/attestation_guard.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import jwt
22
import time
3-
import json
43
import hashlib
54
import os
65
from typing import Dict, Any, Optional
@@ -13,13 +12,17 @@ class AttestationGuard:
1312
def __init__(self, secret_key: str = None, allow_insecure: bool = False):
1413
self.secret = secret_key or os.environ.get("QWED_ATTESTATION_SECRET")
1514
if not self.secret:
16-
if allow_insecure or os.environ.get("QWED_DEV_MODE") == "1":
17-
# deepcode ignore HardcodedSecret: Dev-mode fallback, only active with explicit opt-in
18-
self.secret = "dev-secret-insecure"
19-
else:
20-
raise ValueError("QWED_ATTESTATION_SECRET required. Set allow_insecure=True for dev mode.")
15+
raise ValueError(
16+
"QWED_ATTESTATION_SECRET required. Refusing insecure fallback secret."
17+
)
2118

22-
def sign_verification(self, input_query: str, guard_result: Dict[str, Any], engine: str = "QWED-Deterministic-v1") -> str:
19+
def sign_verification(
20+
self,
21+
input_query: str,
22+
guard_result: Dict[str, Any],
23+
engine: str = "QWED-Deterministic-v1",
24+
timestamp: Optional[float] = None,
25+
) -> str:
2326
"""
2427
Creates a JWT attesting that a specific verification occurred.
2528
Source: QWED Features list.
@@ -28,7 +31,7 @@ def sign_verification(self, input_query: str, guard_result: Dict[str, Any], engi
2831
query_hash = hashlib.sha256(input_query.encode('utf-8')).hexdigest()
2932

3033
payload = {
31-
"timestamp": time.time(),
34+
"timestamp": time.time() if timestamp is None else timestamp,
3235
"query_hash": query_hash,
3336
"verification_result": guard_result.get("verified", False),
3437
"engine": engine,

qwed_sdk/cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def print_stats(self):
257257

258258
try:
259259
from qwed_sdk.qwed_local import QWED, HAS_COLOR
260-
except:
260+
except (ImportError, AttributeError):
261261
HAS_COLOR = False
262262
class QWED:
263263
BRAND = INFO = SUCCESS = VALUE = RESET = ""

scripts/benchmark_hard.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def verify_answer(claude_answer: str, expected, expression: str) -> tuple:
138138
return expected, is_correct
139139

140140
return expected, False
141-
except:
141+
except Exception:
142142
return expected, False
143143

144144
def run_hard_benchmark():

scripts/benchmark_math.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def call_claude(query: str) -> str:
9696
if numbers:
9797
return float(numbers[0])
9898
return None
99-
except:
99+
except Exception:
100100
return None
101101

102102
def verify_with_qwed(query: str, llm_answer: float, expected: float) -> Dict:

scripts/find_azure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
for name, obj in inspect.getmembers(resources):
1313
if "Azure" in name or "Foundry" in name:
1414
print(f"Found in resources: {name}")
15-
except:
16-
pass
15+
except ImportError:
16+
print("anthropic.resources not available; skipping nested resource scan")

scripts/stress_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def send_request(query_id, query):
4040
try:
4141
data = response.json()
4242
result_status = data.get("status", "UNKNOWN")
43-
except:
43+
except Exception:
4444
result_status = "PARSE_ERROR"
4545

4646
return {

src/qwed_new/api/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ async def verify_math(
430430
"simplified": str(simplified),
431431
"original": str(parsed)
432432
}
433-
except:
433+
except Exception:
434434
# Symbolic expression
435435
result = {
436436
"is_valid": True,

src/qwed_new/auth/audit_routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Audit log routes for QWED Enterprise Portal.
33
"""
44
from fastapi import APIRouter, Depends, Query, HTTPException
5-
from typing import Optional, List
5+
from typing import Optional
66
import csv
77
import io
88
from datetime import datetime, timedelta

src/qwed_new/core/ablation_tracker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
markdown = tracker.export_markdown()
2020
"""
2121

22-
from dataclasses import dataclass, field
22+
from dataclasses import dataclass
2323
from typing import Dict, List, Any, Optional
2424
from datetime import datetime
2525
from enum import Enum

0 commit comments

Comments
 (0)