cocoindex 0.1.72__cp313-cp313-macosx_11_0_arm64.whl → 0.1.74__cp313-cp313-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cocoindex/_engine.cpython-313-darwin.so +0 -0
- cocoindex/convert.py +237 -142
- cocoindex/flow.py +2 -1
- cocoindex/op.py +263 -6
- cocoindex/tests/test_convert.py +96 -129
- cocoindex/tests/test_typing.py +94 -211
- cocoindex/typing.py +176 -133
- {cocoindex-0.1.72.dist-info → cocoindex-0.1.74.dist-info}/METADATA +2 -2
- {cocoindex-0.1.72.dist-info → cocoindex-0.1.74.dist-info}/RECORD +12 -12
- {cocoindex-0.1.72.dist-info → cocoindex-0.1.74.dist-info}/WHEEL +0 -0
- {cocoindex-0.1.72.dist-info → cocoindex-0.1.74.dist-info}/entry_points.txt +0 -0
- {cocoindex-0.1.72.dist-info → cocoindex-0.1.74.dist-info}/licenses/LICENSE +0 -0
cocoindex/tests/test_typing.py
CHANGED
@@ -9,6 +9,11 @@ import pytest
|
|
9
9
|
from numpy.typing import NDArray
|
10
10
|
|
11
11
|
from cocoindex.typing import (
|
12
|
+
AnalyzedBasicType,
|
13
|
+
AnalyzedDictType,
|
14
|
+
AnalyzedListType,
|
15
|
+
AnalyzedStructType,
|
16
|
+
AnalyzedUnknownType,
|
12
17
|
AnalyzedTypeInfo,
|
13
18
|
TypeAttr,
|
14
19
|
TypeKind,
|
@@ -33,83 +38,67 @@ class SimpleNamedTuple(NamedTuple):
|
|
33
38
|
def test_ndarray_float32_no_dim() -> None:
|
34
39
|
typ = NDArray[np.float32]
|
35
40
|
result = analyze_type_info(typ)
|
36
|
-
assert result.
|
37
|
-
assert result.vector_info
|
38
|
-
assert result.elem_type == np.float32
|
39
|
-
assert result.key_type is None
|
40
|
-
assert result.struct_type is None
|
41
|
+
assert isinstance(result.variant, AnalyzedListType)
|
42
|
+
assert result.variant.vector_info is None
|
43
|
+
assert result.variant.elem_type == np.float32
|
41
44
|
assert result.nullable is False
|
42
|
-
assert result.
|
43
|
-
assert
|
44
|
-
assert get_args(result.np_number_type)[1] == np.dtype[np.float32]
|
45
|
+
assert get_origin(result.core_type) == np.ndarray
|
46
|
+
assert get_args(result.core_type)[1] == np.dtype[np.float32]
|
45
47
|
|
46
48
|
|
47
49
|
def test_vector_float32_no_dim() -> None:
|
48
50
|
typ = Vector[np.float32]
|
49
51
|
result = analyze_type_info(typ)
|
50
|
-
assert result.
|
51
|
-
assert result.vector_info == VectorInfo(dim=None)
|
52
|
-
assert result.elem_type == np.float32
|
53
|
-
assert result.key_type is None
|
54
|
-
assert result.struct_type is None
|
52
|
+
assert isinstance(result.variant, AnalyzedListType)
|
53
|
+
assert result.variant.vector_info == VectorInfo(dim=None)
|
54
|
+
assert result.variant.elem_type == np.float32
|
55
55
|
assert result.nullable is False
|
56
|
-
assert result.
|
57
|
-
assert
|
58
|
-
assert get_args(result.np_number_type)[1] == np.dtype[np.float32]
|
56
|
+
assert get_origin(result.core_type) == np.ndarray
|
57
|
+
assert get_args(result.core_type)[1] == np.dtype[np.float32]
|
59
58
|
|
60
59
|
|
61
60
|
def test_ndarray_float64_with_dim() -> None:
|
62
61
|
typ = Annotated[NDArray[np.float64], VectorInfo(dim=128)]
|
63
62
|
result = analyze_type_info(typ)
|
64
|
-
assert result.
|
65
|
-
assert result.vector_info == VectorInfo(dim=128)
|
66
|
-
assert result.elem_type == np.float64
|
67
|
-
assert result.key_type is None
|
68
|
-
assert result.struct_type is None
|
63
|
+
assert isinstance(result.variant, AnalyzedListType)
|
64
|
+
assert result.variant.vector_info == VectorInfo(dim=128)
|
65
|
+
assert result.variant.elem_type == np.float64
|
69
66
|
assert result.nullable is False
|
70
|
-
assert result.
|
71
|
-
assert
|
72
|
-
assert get_args(result.np_number_type)[1] == np.dtype[np.float64]
|
67
|
+
assert get_origin(result.core_type) == np.ndarray
|
68
|
+
assert get_args(result.core_type)[1] == np.dtype[np.float64]
|
73
69
|
|
74
70
|
|
75
71
|
def test_vector_float32_with_dim() -> None:
|
76
72
|
typ = Vector[np.float32, Literal[384]]
|
77
73
|
result = analyze_type_info(typ)
|
78
|
-
assert result.
|
79
|
-
assert result.vector_info == VectorInfo(dim=384)
|
80
|
-
assert result.elem_type == np.float32
|
81
|
-
assert result.key_type is None
|
82
|
-
assert result.struct_type is None
|
74
|
+
assert isinstance(result.variant, AnalyzedListType)
|
75
|
+
assert result.variant.vector_info == VectorInfo(dim=384)
|
76
|
+
assert result.variant.elem_type == np.float32
|
83
77
|
assert result.nullable is False
|
84
|
-
assert result.
|
85
|
-
assert
|
86
|
-
assert get_args(result.np_number_type)[1] == np.dtype[np.float32]
|
78
|
+
assert get_origin(result.core_type) == np.ndarray
|
79
|
+
assert get_args(result.core_type)[1] == np.dtype[np.float32]
|
87
80
|
|
88
81
|
|
89
82
|
def test_ndarray_int64_no_dim() -> None:
|
90
83
|
typ = NDArray[np.int64]
|
91
84
|
result = analyze_type_info(typ)
|
92
|
-
assert result.
|
93
|
-
assert result.vector_info
|
94
|
-
assert result.elem_type == np.int64
|
85
|
+
assert isinstance(result.variant, AnalyzedListType)
|
86
|
+
assert result.variant.vector_info is None
|
87
|
+
assert result.variant.elem_type == np.int64
|
95
88
|
assert result.nullable is False
|
96
|
-
assert result.
|
97
|
-
assert
|
98
|
-
assert get_args(result.np_number_type)[1] == np.dtype[np.int64]
|
89
|
+
assert get_origin(result.core_type) == np.ndarray
|
90
|
+
assert get_args(result.core_type)[1] == np.dtype[np.int64]
|
99
91
|
|
100
92
|
|
101
93
|
def test_nullable_ndarray() -> None:
|
102
94
|
typ = NDArray[np.float32] | None
|
103
95
|
result = analyze_type_info(typ)
|
104
|
-
assert result.
|
105
|
-
assert result.vector_info
|
106
|
-
assert result.elem_type == np.float32
|
107
|
-
assert result.key_type is None
|
108
|
-
assert result.struct_type is None
|
96
|
+
assert isinstance(result.variant, AnalyzedListType)
|
97
|
+
assert result.variant.vector_info is None
|
98
|
+
assert result.variant.elem_type == np.float32
|
109
99
|
assert result.nullable is True
|
110
|
-
assert result.
|
111
|
-
assert
|
112
|
-
assert get_args(result.np_number_type)[1] == np.dtype[np.float32]
|
100
|
+
assert get_origin(result.core_type) == np.ndarray
|
101
|
+
assert get_args(result.core_type)[1] == np.dtype[np.float32]
|
113
102
|
|
114
103
|
|
115
104
|
def test_scalar_numpy_types() -> None:
|
@@ -119,59 +108,38 @@ def test_scalar_numpy_types() -> None:
|
|
119
108
|
(np.float64, "Float64"),
|
120
109
|
]:
|
121
110
|
type_info = analyze_type_info(np_type)
|
122
|
-
assert type_info.
|
123
|
-
|
111
|
+
assert isinstance(type_info.variant, AnalyzedBasicType)
|
112
|
+
assert type_info.variant.kind == expected_kind, (
|
113
|
+
f"Expected {expected_kind} for {np_type}, got {type_info.variant.kind}"
|
124
114
|
)
|
125
|
-
assert type_info.
|
126
|
-
f"Expected {np_type}, got {type_info.
|
115
|
+
assert type_info.core_type == np_type, (
|
116
|
+
f"Expected {np_type}, got {type_info.core_type}"
|
127
117
|
)
|
128
|
-
assert type_info.elem_type is None
|
129
|
-
assert type_info.vector_info is None
|
130
118
|
|
131
119
|
|
132
120
|
def test_vector_str() -> None:
|
133
121
|
typ = Vector[str]
|
134
122
|
result = analyze_type_info(typ)
|
135
|
-
assert result.
|
136
|
-
assert result.elem_type is str
|
137
|
-
assert result.vector_info == VectorInfo(dim=None)
|
138
|
-
|
139
|
-
|
140
|
-
def test_vector_complex64() -> None:
|
141
|
-
typ = Vector[np.complex64]
|
142
|
-
result = analyze_type_info(typ)
|
143
|
-
assert result.kind == "Vector"
|
144
|
-
assert result.elem_type == np.complex64
|
145
|
-
assert result.vector_info == VectorInfo(dim=None)
|
123
|
+
assert isinstance(result.variant, AnalyzedListType)
|
124
|
+
assert result.variant.elem_type is str
|
125
|
+
assert result.variant.vector_info == VectorInfo(dim=None)
|
146
126
|
|
147
127
|
|
148
128
|
def test_non_numpy_vector() -> None:
|
149
129
|
typ = Vector[float, Literal[3]]
|
150
130
|
result = analyze_type_info(typ)
|
151
|
-
assert result.
|
152
|
-
assert result.elem_type is float
|
153
|
-
assert result.vector_info == VectorInfo(dim=3)
|
154
|
-
|
155
|
-
|
156
|
-
def test_ndarray_any_dtype() -> None:
|
157
|
-
typ = NDArray[Any]
|
158
|
-
with pytest.raises(
|
159
|
-
TypeError, match="NDArray for Vector must use a concrete numpy dtype"
|
160
|
-
):
|
161
|
-
analyze_type_info(typ)
|
131
|
+
assert isinstance(result.variant, AnalyzedListType)
|
132
|
+
assert result.variant.elem_type is float
|
133
|
+
assert result.variant.vector_info == VectorInfo(dim=3)
|
162
134
|
|
163
135
|
|
164
136
|
def test_list_of_primitives() -> None:
|
165
137
|
typ = list[str]
|
166
138
|
result = analyze_type_info(typ)
|
167
139
|
assert result == AnalyzedTypeInfo(
|
168
|
-
kind="Vector",
|
169
140
|
core_type=list[str],
|
170
|
-
|
171
|
-
elem_type=str,
|
172
|
-
key_type=None,
|
173
|
-
struct_type=None,
|
174
|
-
np_number_type=None,
|
141
|
+
base_type=list,
|
142
|
+
variant=AnalyzedListType(elem_type=str, vector_info=None),
|
175
143
|
attrs=None,
|
176
144
|
nullable=False,
|
177
145
|
)
|
@@ -181,13 +149,9 @@ def test_list_of_structs() -> None:
|
|
181
149
|
typ = list[SimpleDataclass]
|
182
150
|
result = analyze_type_info(typ)
|
183
151
|
assert result == AnalyzedTypeInfo(
|
184
|
-
kind="LTable",
|
185
152
|
core_type=list[SimpleDataclass],
|
186
|
-
|
187
|
-
elem_type=SimpleDataclass,
|
188
|
-
key_type=None,
|
189
|
-
struct_type=None,
|
190
|
-
np_number_type=None,
|
153
|
+
base_type=list,
|
154
|
+
variant=AnalyzedListType(elem_type=SimpleDataclass, vector_info=None),
|
191
155
|
attrs=None,
|
192
156
|
nullable=False,
|
193
157
|
)
|
@@ -197,13 +161,9 @@ def test_sequence_of_int() -> None:
|
|
197
161
|
typ = Sequence[int]
|
198
162
|
result = analyze_type_info(typ)
|
199
163
|
assert result == AnalyzedTypeInfo(
|
200
|
-
kind="Vector",
|
201
164
|
core_type=Sequence[int],
|
202
|
-
|
203
|
-
elem_type=int,
|
204
|
-
key_type=None,
|
205
|
-
struct_type=None,
|
206
|
-
np_number_type=None,
|
165
|
+
base_type=Sequence,
|
166
|
+
variant=AnalyzedListType(elem_type=int, vector_info=None),
|
207
167
|
attrs=None,
|
208
168
|
nullable=False,
|
209
169
|
)
|
@@ -213,13 +173,9 @@ def test_list_with_vector_info() -> None:
|
|
213
173
|
typ = Annotated[list[int], VectorInfo(dim=5)]
|
214
174
|
result = analyze_type_info(typ)
|
215
175
|
assert result == AnalyzedTypeInfo(
|
216
|
-
kind="Vector",
|
217
176
|
core_type=list[int],
|
218
|
-
|
219
|
-
elem_type=int,
|
220
|
-
key_type=None,
|
221
|
-
struct_type=None,
|
222
|
-
np_number_type=None,
|
177
|
+
base_type=list,
|
178
|
+
variant=AnalyzedListType(elem_type=int, vector_info=VectorInfo(dim=5)),
|
223
179
|
attrs=None,
|
224
180
|
nullable=False,
|
225
181
|
)
|
@@ -229,13 +185,9 @@ def test_dict_str_int() -> None:
|
|
229
185
|
typ = dict[str, int]
|
230
186
|
result = analyze_type_info(typ)
|
231
187
|
assert result == AnalyzedTypeInfo(
|
232
|
-
kind="KTable",
|
233
188
|
core_type=dict[str, int],
|
234
|
-
|
235
|
-
|
236
|
-
key_type=None,
|
237
|
-
struct_type=None,
|
238
|
-
np_number_type=None,
|
189
|
+
base_type=dict,
|
190
|
+
variant=AnalyzedDictType(key_type=str, value_type=int),
|
239
191
|
attrs=None,
|
240
192
|
nullable=False,
|
241
193
|
)
|
@@ -245,13 +197,9 @@ def test_mapping_str_dataclass() -> None:
|
|
245
197
|
typ = Mapping[str, SimpleDataclass]
|
246
198
|
result = analyze_type_info(typ)
|
247
199
|
assert result == AnalyzedTypeInfo(
|
248
|
-
kind="KTable",
|
249
200
|
core_type=Mapping[str, SimpleDataclass],
|
250
|
-
|
251
|
-
|
252
|
-
key_type=None,
|
253
|
-
struct_type=None,
|
254
|
-
np_number_type=None,
|
201
|
+
base_type=Mapping,
|
202
|
+
variant=AnalyzedDictType(key_type=str, value_type=SimpleDataclass),
|
255
203
|
attrs=None,
|
256
204
|
nullable=False,
|
257
205
|
)
|
@@ -261,13 +209,9 @@ def test_dataclass() -> None:
|
|
261
209
|
typ = SimpleDataclass
|
262
210
|
result = analyze_type_info(typ)
|
263
211
|
assert result == AnalyzedTypeInfo(
|
264
|
-
kind="Struct",
|
265
212
|
core_type=SimpleDataclass,
|
266
|
-
|
267
|
-
|
268
|
-
key_type=None,
|
269
|
-
struct_type=SimpleDataclass,
|
270
|
-
np_number_type=None,
|
213
|
+
base_type=SimpleDataclass,
|
214
|
+
variant=AnalyzedStructType(struct_type=SimpleDataclass),
|
271
215
|
attrs=None,
|
272
216
|
nullable=False,
|
273
217
|
)
|
@@ -277,29 +221,9 @@ def test_named_tuple() -> None:
|
|
277
221
|
typ = SimpleNamedTuple
|
278
222
|
result = analyze_type_info(typ)
|
279
223
|
assert result == AnalyzedTypeInfo(
|
280
|
-
kind="Struct",
|
281
224
|
core_type=SimpleNamedTuple,
|
282
|
-
|
283
|
-
|
284
|
-
key_type=None,
|
285
|
-
struct_type=SimpleNamedTuple,
|
286
|
-
np_number_type=None,
|
287
|
-
attrs=None,
|
288
|
-
nullable=False,
|
289
|
-
)
|
290
|
-
|
291
|
-
|
292
|
-
def test_tuple_key_value() -> None:
|
293
|
-
typ = (str, int)
|
294
|
-
result = analyze_type_info(typ)
|
295
|
-
assert result == AnalyzedTypeInfo(
|
296
|
-
kind="Int64",
|
297
|
-
core_type=int,
|
298
|
-
vector_info=None,
|
299
|
-
elem_type=None,
|
300
|
-
key_type=str,
|
301
|
-
struct_type=None,
|
302
|
-
np_number_type=None,
|
225
|
+
base_type=SimpleNamedTuple,
|
226
|
+
variant=AnalyzedStructType(struct_type=SimpleNamedTuple),
|
303
227
|
attrs=None,
|
304
228
|
nullable=False,
|
305
229
|
)
|
@@ -309,13 +233,9 @@ def test_str() -> None:
|
|
309
233
|
typ = str
|
310
234
|
result = analyze_type_info(typ)
|
311
235
|
assert result == AnalyzedTypeInfo(
|
312
|
-
kind="Str",
|
313
236
|
core_type=str,
|
314
|
-
|
315
|
-
|
316
|
-
key_type=None,
|
317
|
-
struct_type=None,
|
318
|
-
np_number_type=None,
|
237
|
+
base_type=str,
|
238
|
+
variant=AnalyzedBasicType(kind="Str"),
|
319
239
|
attrs=None,
|
320
240
|
nullable=False,
|
321
241
|
)
|
@@ -325,13 +245,9 @@ def test_bool() -> None:
|
|
325
245
|
typ = bool
|
326
246
|
result = analyze_type_info(typ)
|
327
247
|
assert result == AnalyzedTypeInfo(
|
328
|
-
kind="Bool",
|
329
248
|
core_type=bool,
|
330
|
-
|
331
|
-
|
332
|
-
key_type=None,
|
333
|
-
struct_type=None,
|
334
|
-
np_number_type=None,
|
249
|
+
base_type=bool,
|
250
|
+
variant=AnalyzedBasicType(kind="Bool"),
|
335
251
|
attrs=None,
|
336
252
|
nullable=False,
|
337
253
|
)
|
@@ -341,13 +257,9 @@ def test_bytes() -> None:
|
|
341
257
|
typ = bytes
|
342
258
|
result = analyze_type_info(typ)
|
343
259
|
assert result == AnalyzedTypeInfo(
|
344
|
-
kind="Bytes",
|
345
260
|
core_type=bytes,
|
346
|
-
|
347
|
-
|
348
|
-
key_type=None,
|
349
|
-
struct_type=None,
|
350
|
-
np_number_type=None,
|
261
|
+
base_type=bytes,
|
262
|
+
variant=AnalyzedBasicType(kind="Bytes"),
|
351
263
|
attrs=None,
|
352
264
|
nullable=False,
|
353
265
|
)
|
@@ -357,13 +269,9 @@ def test_uuid() -> None:
|
|
357
269
|
typ = uuid.UUID
|
358
270
|
result = analyze_type_info(typ)
|
359
271
|
assert result == AnalyzedTypeInfo(
|
360
|
-
kind="Uuid",
|
361
272
|
core_type=uuid.UUID,
|
362
|
-
|
363
|
-
|
364
|
-
key_type=None,
|
365
|
-
struct_type=None,
|
366
|
-
np_number_type=None,
|
273
|
+
base_type=uuid.UUID,
|
274
|
+
variant=AnalyzedBasicType(kind="Uuid"),
|
367
275
|
attrs=None,
|
368
276
|
nullable=False,
|
369
277
|
)
|
@@ -373,13 +281,9 @@ def test_date() -> None:
|
|
373
281
|
typ = datetime.date
|
374
282
|
result = analyze_type_info(typ)
|
375
283
|
assert result == AnalyzedTypeInfo(
|
376
|
-
kind="Date",
|
377
284
|
core_type=datetime.date,
|
378
|
-
|
379
|
-
|
380
|
-
key_type=None,
|
381
|
-
struct_type=None,
|
382
|
-
np_number_type=None,
|
285
|
+
base_type=datetime.date,
|
286
|
+
variant=AnalyzedBasicType(kind="Date"),
|
383
287
|
attrs=None,
|
384
288
|
nullable=False,
|
385
289
|
)
|
@@ -389,13 +293,9 @@ def test_time() -> None:
|
|
389
293
|
typ = datetime.time
|
390
294
|
result = analyze_type_info(typ)
|
391
295
|
assert result == AnalyzedTypeInfo(
|
392
|
-
kind="Time",
|
393
296
|
core_type=datetime.time,
|
394
|
-
|
395
|
-
|
396
|
-
key_type=None,
|
397
|
-
struct_type=None,
|
398
|
-
np_number_type=None,
|
297
|
+
base_type=datetime.time,
|
298
|
+
variant=AnalyzedBasicType(kind="Time"),
|
399
299
|
attrs=None,
|
400
300
|
nullable=False,
|
401
301
|
)
|
@@ -405,13 +305,9 @@ def test_timedelta() -> None:
|
|
405
305
|
typ = datetime.timedelta
|
406
306
|
result = analyze_type_info(typ)
|
407
307
|
assert result == AnalyzedTypeInfo(
|
408
|
-
kind="TimeDelta",
|
409
308
|
core_type=datetime.timedelta,
|
410
|
-
|
411
|
-
|
412
|
-
key_type=None,
|
413
|
-
struct_type=None,
|
414
|
-
np_number_type=None,
|
309
|
+
base_type=datetime.timedelta,
|
310
|
+
variant=AnalyzedBasicType(kind="TimeDelta"),
|
415
311
|
attrs=None,
|
416
312
|
nullable=False,
|
417
313
|
)
|
@@ -421,13 +317,9 @@ def test_float() -> None:
|
|
421
317
|
typ = float
|
422
318
|
result = analyze_type_info(typ)
|
423
319
|
assert result == AnalyzedTypeInfo(
|
424
|
-
kind="Float64",
|
425
320
|
core_type=float,
|
426
|
-
|
427
|
-
|
428
|
-
key_type=None,
|
429
|
-
struct_type=None,
|
430
|
-
np_number_type=None,
|
321
|
+
base_type=float,
|
322
|
+
variant=AnalyzedBasicType(kind="Float64"),
|
431
323
|
attrs=None,
|
432
324
|
nullable=False,
|
433
325
|
)
|
@@ -437,13 +329,9 @@ def test_int() -> None:
|
|
437
329
|
typ = int
|
438
330
|
result = analyze_type_info(typ)
|
439
331
|
assert result == AnalyzedTypeInfo(
|
440
|
-
kind="Int64",
|
441
332
|
core_type=int,
|
442
|
-
|
443
|
-
|
444
|
-
key_type=None,
|
445
|
-
struct_type=None,
|
446
|
-
np_number_type=None,
|
333
|
+
base_type=int,
|
334
|
+
variant=AnalyzedBasicType(kind="Int64"),
|
447
335
|
attrs=None,
|
448
336
|
nullable=False,
|
449
337
|
)
|
@@ -453,13 +341,9 @@ def test_type_with_attributes() -> None:
|
|
453
341
|
typ = Annotated[str, TypeAttr("key", "value")]
|
454
342
|
result = analyze_type_info(typ)
|
455
343
|
assert result == AnalyzedTypeInfo(
|
456
|
-
kind="Str",
|
457
344
|
core_type=str,
|
458
|
-
|
459
|
-
|
460
|
-
key_type=None,
|
461
|
-
struct_type=None,
|
462
|
-
np_number_type=None,
|
345
|
+
base_type=str,
|
346
|
+
variant=AnalyzedBasicType(kind="Str"),
|
463
347
|
attrs={"key": "value"},
|
464
348
|
nullable=False,
|
465
349
|
)
|
@@ -494,7 +378,7 @@ def test_encode_enriched_type_ltable() -> None:
|
|
494
378
|
typ = list[SimpleDataclass]
|
495
379
|
result = encode_enriched_type(typ)
|
496
380
|
assert result["type"]["kind"] == "LTable"
|
497
|
-
assert result["type"]["row"]
|
381
|
+
assert "fields" in result["type"]["row"]
|
498
382
|
assert len(result["type"]["row"]["fields"]) == 2
|
499
383
|
|
500
384
|
|
@@ -525,22 +409,21 @@ def test_encode_scalar_numpy_types_schema() -> None:
|
|
525
409
|
assert not schema.get("nullable", False)
|
526
410
|
|
527
411
|
|
528
|
-
def
|
412
|
+
def test_annotated_struct_with_type_kind() -> None:
|
529
413
|
typ = Annotated[SimpleDataclass, TypeKind("Vector")]
|
530
|
-
|
531
|
-
|
414
|
+
result = analyze_type_info(typ)
|
415
|
+
assert isinstance(result.variant, AnalyzedBasicType)
|
416
|
+
assert result.variant.kind == "Vector"
|
532
417
|
|
533
418
|
|
534
|
-
def
|
419
|
+
def test_annotated_list_with_type_kind() -> None:
|
535
420
|
typ = Annotated[list[int], TypeKind("Struct")]
|
536
|
-
|
537
|
-
|
421
|
+
result = analyze_type_info(typ)
|
422
|
+
assert isinstance(result.variant, AnalyzedBasicType)
|
423
|
+
assert result.variant.kind == "Struct"
|
538
424
|
|
539
425
|
|
540
|
-
def
|
426
|
+
def test_unknown_type() -> None:
|
541
427
|
typ = set
|
542
|
-
|
543
|
-
|
544
|
-
match="Unsupported as a specific type annotation for CocoIndex data type.*: <class 'set'>",
|
545
|
-
):
|
546
|
-
analyze_type_info(typ)
|
428
|
+
result = analyze_type_info(typ)
|
429
|
+
assert isinstance(result.variant, AnalyzedUnknownType)
|