From 7e41c44d0d6ef91fc11a76103b5e72f1a6cb99ff Mon Sep 17 00:00:00 2001 From: haosenwang1018 Date: Wed, 25 Feb 2026 02:48:40 +0000 Subject: [PATCH] fix: replace 3 bare excepts with except Exception - agentflow/models/initializer.py: model init fallback - test/calculate_score_unified.py: score parsing - util/get_pub_ip.py: network request fallback --- agentflow/agentflow/models/initializer.py | 2 +- test/calculate_score_unified.py | 2 +- util/get_pub_ip.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/agentflow/agentflow/models/initializer.py b/agentflow/agentflow/models/initializer.py index c8832ad..ae881fe 100644 --- a/agentflow/agentflow/models/initializer.py +++ b/agentflow/agentflow/models/initializer.py @@ -42,7 +42,7 @@ def _get_optimal_workers(max_workers: int = None) -> tuple[int, str]: try: external_parallelism = int(slurm_ntasks) detection_method = "SLURM" - except: + except Exception: pass # Calculate optimal workers diff --git a/test/calculate_score_unified.py b/test/calculate_score_unified.py index d6d5075..a8b2a47 100644 --- a/test/calculate_score_unified.py +++ b/test/calculate_score_unified.py @@ -83,7 +83,7 @@ def find_most_similar_candidate(query: str, candidates: list) -> str: for opt in candidates: if val in opt: return opt - except: + except Exception: pass return candidates[0] if candidates else query # worst case fallback diff --git a/util/get_pub_ip.py b/util/get_pub_ip.py index 232a740..f78ade4 100644 --- a/util/get_pub_ip.py +++ b/util/get_pub_ip.py @@ -15,7 +15,7 @@ def get_public_ip_with_fallback(): if response.status_code == 200 and valid_ip(ip): print(f"✅ Successfully got public IP: {ip} from {service}.") return ip - except: + except Exception: continue return "Failed to fetch public IP QAQ. "