From dc7e0fc6bd3a9542306f6271b9793a2969f79e22 Mon Sep 17 00:00:00 2001 From: lou lecrivain Date: Mon, 23 Feb 2026 16:39:41 +0100 Subject: [PATCH] update typing of common "head()" function to reflect None return makes typing issues throughout the source code visible to mypy whereas they previously weren't --- cosmo/common.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cosmo/common.py b/cosmo/common.py index c5a164a..77fed47 100644 --- a/cosmo/common.py +++ b/cosmo/common.py @@ -53,8 +53,10 @@ def strictly_decreasing(l: Sequence[Comparable]) -> bool: # next() can raise StopIteration, so that's why I use this function -# FIXME: should be head[T](l: list[T]) -> Optional[T] -def head(l): +T = TypeVar("T") + + +def head(l: list[T]) -> Optional[T]: return None if not l else l[0]