Skip to content

Commit 38e9f61

Browse files
author
Val Brodsky
committed
Dealing with constrained types
1 parent 639f2ff commit 38e9f61

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

libs/labelbox/src/labelbox/data/annotation_types/types.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import sys
22
from typing import Generic, TypeVar, Any
33

4+
from pydantic import StringConstraints
5+
46
from typing_extensions import Annotated
57
from packaging import version
68
import numpy as np
79

8-
from pydantic import BaseModel
10+
from pydantic import Field
911

10-
Cuid = Annotated[str, pydantic_compat.Field(min_length=25, max_length=25)]
12+
Cuid = Annotated[str, StringConstraints(min_length=25, max_length=25)]
1113

1214
DType = TypeVar('DType')
1315
DShape = TypeVar('DShape')

libs/labelbox/src/labelbox/schema/bulk_import_request.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
from google.api_core import retry
99
from labelbox import parser
1010
import requests
11-
from pydantic import BaseModel, model_validator
11+
from pydantic import BaseModel, model_validator, StringConstraints
1212
from typing_extensions import Literal
1313
from typing import (Any, List, Optional, BinaryIO, Dict, Iterable, Tuple, Union,
14-
Type, Set, TYPE_CHECKING)
14+
Type, Set, TYPE_CHECKING, Annotated)
1515

1616
from labelbox import exceptions as lb_exceptions
1717
from labelbox.orm.model import Entity
@@ -502,7 +502,7 @@ def get_mal_schemas(ontology):
502502
return valid_feature_schemas_by_schema_id, valid_feature_schemas_by_name
503503

504504

505-
LabelboxID: str = pydantic_compat.Field(..., min_length=25, max_length=25)
505+
LabelboxID = Annotated[str, StringConstraints(min_length=25, max_length=25)]
506506

507507

508508
class Bbox(BaseModel):

libs/labelbox/src/labelbox/schema/ontology.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from labelbox.exceptions import InconsistentOntologyException
1212
from labelbox.orm.db_object import DbObject
1313
from labelbox.orm.model import Field, Relationship
14-
from pydantic import BaseModel
1514
import json
1615

1716
FeatureSchemaId: Type[str] = Annotated[

0 commit comments

Comments
 (0)