From 1c5a2337e8830cee7759bdc87d3203a105f8ed5e Mon Sep 17 00:00:00 2001 From: henryruhs Date: Mon, 10 Mar 2025 08:17:05 +0100 Subject: [PATCH] Make get_first and get_last safe --- facefusion/common_helper.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/facefusion/common_helper.py b/facefusion/common_helper.py index 79c549a..5035a2c 100644 --- a/facefusion/common_helper.py +++ b/facefusion/common_helper.py @@ -1,5 +1,5 @@ import platform -from typing import Any, Optional, Sequence +from typing import Any, Optional, Sequence, List def is_linux() -> bool: @@ -73,8 +73,12 @@ def cast_bool(value : Any) -> Optional[bool]: def get_first(__list__ : Any) -> Any: - return next(iter(__list__), None) + if isinstance(__list__, List): + return next(iter(__list__), None) + return None def get_last(__list__ : Any) -> Any: - return next(reversed(__list__), None) + if isinstance(__list__, List): + return next(reversed(__list__), None) + return None