From 7ba39cec3e6aa637839d2d1ab02481da8a073bd6 Mon Sep 17 00:00:00 2001 From: lemorage Date: Mon, 30 Jun 2025 09:00:49 +0200 Subject: [PATCH 1/2] fix(ci): add numpy to dependencies and pass typing checks --- pyproject.toml | 1 + python/cocoindex/functions.py | 15 ++++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index edff1091e..afb318b38 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,7 @@ dependencies = [ "rich>=14.0.0", "python-dotenv>=1.1.0", "watchfiles>=1.1.0", + "numpy>=2.3.1", ] license = "Apache-2.0" urls = { Homepage = "https://cocoindex.io/" } diff --git a/python/cocoindex/functions.py b/python/cocoindex/functions.py index 58f41eb24..2b9ae1802 100644 --- a/python/cocoindex/functions.py +++ b/python/cocoindex/functions.py @@ -1,20 +1,17 @@ """All builtin functions.""" -from typing import Annotated, Any, TYPE_CHECKING, Literal -import numpy as np -from numpy.typing import NDArray import dataclasses +from typing import Annotated, Any, Literal -from .typing import Float32, Vector, TypeAttr -from . import op, llm +import numpy as np +from numpy.typing import NDArray -# Libraries that are heavy to import. Lazily import them later. -if TYPE_CHECKING: - import sentence_transformers +from . import llm, op +from .typing import TypeAttr, Vector # Check if sentence_transformers is available try: - import sentence_transformers + import sentence_transformers # type: ignore _SENTENCE_TRANSFORMERS_AVAILABLE = True except ImportError: From d76a7ab631fd8e2a5e73cd118e7de8e45f3bd4c4 Mon Sep 17 00:00:00 2001 From: lemorage Date: Mon, 30 Jun 2025 10:34:10 +0200 Subject: [PATCH 2/2] fix: relax numpy version requirement In NumPy release 1.23.2, Python 3.11 support was added. See https://github.com/numpy/numpy/releases/tag/v1.23.2. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index afb318b38..e13aec773 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ dependencies = [ "rich>=14.0.0", "python-dotenv>=1.1.0", "watchfiles>=1.1.0", - "numpy>=2.3.1", + "numpy>=1.23.2", ] license = "Apache-2.0" urls = { Homepage = "https://cocoindex.io/" }