From 64a96b8a41b6e9cac05ec0996db7ee1fe68444be Mon Sep 17 00:00:00 2001 From: Patrick Kunzmann Date: Sun, 15 Dec 2024 14:20:20 +0100 Subject: [PATCH] Fix exception on empty list --- doc/switcher.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/switcher.py b/doc/switcher.py index b9eb57059..5bd6202fc 100644 --- a/doc/switcher.py +++ b/doc/switcher.py @@ -92,6 +92,7 @@ def create_switcher_json(file_path, min_tag, n_versions): } ) # Mark the latest version as preferred - version_config[-1]["preferred"] = True + if len(version_config) > 0: + version_config[-1]["preferred"] = True with open(file_path, "w") as file: json.dump(version_config, file, indent=4)