Make get_first and get_last safe

This commit is contained in:
henryruhs
2025-03-10 08:23:35 +01:00
parent 1c5a2337e8
commit 4c09f88b42

View File

@@ -73,12 +73,12 @@ def cast_bool(value : Any) -> Optional[bool]:
def get_first(__list__ : Any) -> Any: def get_first(__list__ : Any) -> Any:
if isinstance(__list__, List): if isinstance(__list__, list):
return next(iter(__list__), None) return next(iter(__list__), None)
return None return None
def get_last(__list__ : Any) -> Any: def get_last(__list__ : Any) -> Any:
if isinstance(__list__, List): if isinstance(__list__, list):
return next(reversed(__list__), None) return next(reversed(__list__), None)
return None return None