From a2fe6cbc38ec6c3f9b6d96511744f9849d359ed6 Mon Sep 17 00:00:00 2001 From: Alvaro Valdebenito Date: Wed, 28 Aug 2024 16:26:01 +0200 Subject: [PATCH] ruff E722 Do not use bare `except` --- scripts/check_broken_links.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/check_broken_links.py b/scripts/check_broken_links.py index f2022cc..16a15f7 100755 --- a/scripts/check_broken_links.py +++ b/scripts/check_broken_links.py @@ -2,15 +2,15 @@ """See check_broken_links.py --help for usage""" -import os import argparse -from datetime import datetime +import os from concurrent.futures import ThreadPoolExecutor +from datetime import datetime import requests -import airbase as ab from tqdm import tqdm +import airbase as ab REQUESTS_SESSION_CONNECTION_POOL_SIZE = 10 @@ -18,7 +18,7 @@ def main(output_file, retries, ignore_errors=False): """Check the entire AirBase database for broken links""" - print("Will output bad links to {}".format(output_file)) + print(f"Will output bad links to {output_file}") client = ab.AirbaseClient() req = client.request(preload_csv_links=True) # get links to all files @@ -29,7 +29,7 @@ def is_404(url, r=retries): try: response = session.head(url, timeout=1) return response.status_code == 404 - except: + except Exception: if r == 0 and not ignore_errors: raise elif r == 0 and ignore_errors: @@ -70,7 +70,7 @@ def is_404(url, r=retries): parser.add_argument( "-o", "--output", - default="bad-links-{}.txt".format(now), + default=f"bad-links-{now}.txt", help="File to record the broken links in", type=argparse.FileType(), )