From 2d724827449c3e6fbcdfe591017fd0091a61bbd4 Mon Sep 17 00:00:00 2001 From: haosenwang1018 Date: Wed, 25 Feb 2026 04:07:17 +0000 Subject: [PATCH] fix: replace 5 bare excepts with except Exception in bio-research scripts Bare `except:` clauses catch `KeyboardInterrupt` and `SystemExit`, which can mask real errors and make debugging harder. Replace with `except Exception:` to preserve the intended error-suppression behavior while allowing system-level exceptions to propagate normally. Files changed: - bio-research/skills/nextflow-development/scripts/check_environment.py (4 sites) - bio-research/skills/nextflow-development/scripts/detect_data_type.py (1 site) --- .../nextflow-development/scripts/check_environment.py | 8 ++++---- .../nextflow-development/scripts/detect_data_type.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bio-research/skills/nextflow-development/scripts/check_environment.py b/bio-research/skills/nextflow-development/scripts/check_environment.py index 2e505d5..efa5ac6 100644 --- a/bio-research/skills/nextflow-development/scripts/check_environment.py +++ b/bio-research/skills/nextflow-development/scripts/check_environment.py @@ -260,7 +260,7 @@ def check_resources() -> CheckResult: ) if result.returncode == 0: mem_gb = int(result.stdout.strip()) / (1024**3) - except: + except Exception: pass # Disk space (current directory) @@ -268,7 +268,7 @@ def check_resources() -> CheckResult: try: statvfs = os.statvfs('.') disk_gb = (statvfs.f_frsize * statvfs.f_bavail) / (1024**3) - except: + except Exception: pass details = f"CPUs: {cpu_count}, Memory: {mem_gb:.1f}GB, Disk: {disk_gb:.1f}GB available" @@ -319,7 +319,7 @@ def check_network() -> CheckResult: req = urllib.request.Request("https://hub.docker.com", headers=headers) urllib.request.urlopen(req, timeout=10) docker_hub_ok = True - except: + except Exception: docker_hub_ok = False # Try nf-core (for pipeline downloads) @@ -327,7 +327,7 @@ def check_network() -> CheckResult: req = urllib.request.Request("https://nf-co.re", headers=headers) urllib.request.urlopen(req, timeout=10) nfcore_ok = True - except: + except Exception: nfcore_ok = False if docker_hub_ok and nfcore_ok: diff --git a/bio-research/skills/nextflow-development/scripts/detect_data_type.py b/bio-research/skills/nextflow-development/scripts/detect_data_type.py index 870b064..e3acd71 100644 --- a/bio-research/skills/nextflow-development/scripts/detect_data_type.py +++ b/bio-research/skills/nextflow-development/scripts/detect_data_type.py @@ -71,7 +71,7 @@ def scan_directory(directory: str) -> Dict: try: size = os.path.getsize(os.path.join(root, filename)) info['total_size_gb'] += size / (1024**3) - except: + except Exception: pass return info