Skip to content

Commit e08ee93

Browse files
authored
fix(query-handler): allow QueryOutput without type var (#1041)
1 parent c227b3c commit e08ee93

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ authors = [{ name = "CocoIndex", email = "[email protected]" }]
1010
readme = "README.md"
1111
requires-python = ">=3.11"
1212
dependencies = [
13+
"typing-extensions>=4.12; python_version < '3.13'",
1314
"click>=8.1.8",
1415
"rich>=14.0.0",
1516
"python-dotenv>=1.1.0",

python/cocoindex/query_handler.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import dataclasses
22
import numpy as np
33
from numpy import typing as npt
4-
from typing import Generic, TypeVar
4+
from typing import Generic, Any
55
from .index import VectorSimilarityMetric
6+
import sys
7+
8+
if sys.version_info >= (3, 13):
9+
from typing import TypeVar
10+
else:
11+
from typing_extensions import TypeVar # PEP 696 backport
612

713

814
@dataclasses.dataclass
@@ -35,7 +41,7 @@ class QueryInfo:
3541
similarity_metric: VectorSimilarityMetric | None = None
3642

3743

38-
R = TypeVar("R")
44+
R = TypeVar("R", default=Any)
3945

4046

4147
@dataclasses.dataclass

0 commit comments

Comments
 (0)