From d453a430104bf621280af72a6c9ae09969d85121 Mon Sep 17 00:00:00 2001 From: nanglo123 Date: Thu, 12 Sep 2024 16:43:24 -0400 Subject: [PATCH] Remove invalid prefixes after dictionary iteration --- src/pyobo/constants.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pyobo/constants.py b/src/pyobo/constants.py index 5726d2dc..4eb43d55 100644 --- a/src/pyobo/constants.py +++ b/src/pyobo/constants.py @@ -106,11 +106,14 @@ VERSION_PINS = {} else: VERSION_PINS = json.loads(VERSION_PINS_STR) - for k, v in VERSION_PINS.items(): - if not isinstance(k, str) or not isinstance(v, str): + invalid_prefixes = [] + for prefix, version in VERSION_PINS.items(): + if not isinstance(prefix, str) or not isinstance(version, str): logger.error( - f"The prefix: {k} and version: {v} name must both be strings") - VERSION_PINS.pop(k) + f"The prefix:{prefix} and version:{version} name must both be strings") + invalid_prefixes.append(prefix) + for prefix in invalid_prefixes: + VERSION_PINS.pop(prefix) except ValueError as e: logger.error( "The value for the environment variable VERSION_PINS must be a valid JSON string: %s" % e