Skip to content

Commit 9659c68

Browse files
fix: replace 5 bare excepts with except Exception in bio-research scripts (#82)
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) Co-authored-by: haosenwang1018 <haosenwang1018@users.noreply.github.com>
1 parent e7a5e58 commit 9659c68

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

bio-research/skills/nextflow-development/scripts/check_environment.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,15 +260,15 @@ def check_resources() -> CheckResult:
260260
)
261261
if result.returncode == 0:
262262
mem_gb = int(result.stdout.strip()) / (1024**3)
263-
except:
263+
except Exception:
264264
pass
265265

266266
# Disk space (current directory)
267267
disk_gb = 0
268268
try:
269269
statvfs = os.statvfs('.')
270270
disk_gb = (statvfs.f_frsize * statvfs.f_bavail) / (1024**3)
271-
except:
271+
except Exception:
272272
pass
273273

274274
details = f"CPUs: {cpu_count}, Memory: {mem_gb:.1f}GB, Disk: {disk_gb:.1f}GB available"
@@ -319,15 +319,15 @@ def check_network() -> CheckResult:
319319
req = urllib.request.Request("https://hub.docker.com", headers=headers)
320320
urllib.request.urlopen(req, timeout=10)
321321
docker_hub_ok = True
322-
except:
322+
except Exception:
323323
docker_hub_ok = False
324324

325325
# Try nf-core (for pipeline downloads)
326326
try:
327327
req = urllib.request.Request("https://nf-co.re", headers=headers)
328328
urllib.request.urlopen(req, timeout=10)
329329
nfcore_ok = True
330-
except:
330+
except Exception:
331331
nfcore_ok = False
332332

333333
if docker_hub_ok and nfcore_ok:

bio-research/skills/nextflow-development/scripts/detect_data_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def scan_directory(directory: str) -> Dict:
7171
try:
7272
size = os.path.getsize(os.path.join(root, filename))
7373
info['total_size_gb'] += size / (1024**3)
74-
except:
74+
except Exception:
7575
pass
7676

7777
return info

0 commit comments

Comments
 (0)