File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
libs/labelbox/src/labelbox/data/annotation_types Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change 1
1
import sys
2
2
from typing import Generic , TypeVar , Any
3
3
4
- from pydantic import StringConstraints
5
-
6
4
from typing_extensions import Annotated
7
5
from packaging import version
8
6
import numpy as np
9
7
10
8
from pydantic import ValidationInfo
9
+ from labelbox import pydantic_compat
11
10
12
- Cuid = Annotated [str , StringConstraints (min_length = 25 , max_length = 25 )]
11
+ Cuid = Annotated [str , pydantic_compat . Field (min_length = 25 , max_length = 25 )]
13
12
14
13
DType = TypeVar ('DType' )
15
14
DShape = TypeVar ('DShape' )
@@ -22,11 +21,11 @@ def __get_validators__(cls):
22
21
yield cls .validate
23
22
24
23
@classmethod
25
- def validate (cls , val , field : ValidationInfo ):
24
+ def validate (cls , val , field_info : ValidationInfo ):
26
25
if not isinstance (val , np .ndarray ):
27
26
raise TypeError (f"Expected numpy array. Found { type (val )} " )
28
27
29
- actual_dtype = field . sub_fields [ - 1 ].type_ .__args__ [0 ]
28
+ actual_dtype = cls . model_fields [ field_info . name ].type_ .__args__ [0 ]
30
29
31
30
if val .dtype != actual_dtype :
32
31
raise TypeError (
You can’t perform that action at this time.
0 commit comments