Skip to content

Commit 7f2bc7b

Browse files
author
Matt Sokoloff
committed
3.6 compatibility
1 parent b36ff0a commit 7f2bc7b

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

labelbox/data/annotation_types/types.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import sys
2+
import logging
13
from typing import Generic, TypeVar
24
from typing_extensions import Annotated
35

@@ -9,6 +11,8 @@
911

1012
DType = TypeVar('DType')
1113

14+
logger = logging.getLogger(__name__)
15+
1216

1317
class TypedArray(np.ndarray, Generic[DType]):
1418

@@ -20,8 +24,12 @@ def __get_validators__(cls):
2024
def validate(cls, val, field: ModelField):
2125
if not isinstance(val, np.ndarray):
2226
raise TypeError(f"Expected numpy array. Found {type(val)}")
23-
dtype_field = field.sub_fields[0]
24-
actual_dtype = dtype_field.type_.__args__[0]
27+
28+
if sys.version_info.minor > 6:
29+
actual_dtype = field.sub_fields[0].type_.__args__[0]
30+
else:
31+
actual_dtype = field.sub_fields[0].type_.__values__[0]
32+
2533
if val.dtype != actual_dtype:
2634
raise TypeError(
2735
f"Expected numpy array have type {actual_dtype}. Found {val.dtype}"

setup.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@
2222
install_requires=[
2323
"backoff==1.10.0",
2424
"backports-datetime-fromisoformat==1.0.0; python_version < '3.7.0'",
25-
"dataclasses==0.7; python_version < '3.7.0'", "ndjson==0.3.1",
26-
"requests>=2.22.0", "google-api-core>=1.22.1", "pydantic>=1.8,<2.0",
25+
"dataclasses==0.7; python_version < '3.7.0'",
26+
"ndjson==0.3.1",
27+
"requests>=2.22.0",
28+
"google-api-core>=1.22.1",
29+
"pydantic>=1.8,<2.0",
2730
],
2831
extras_require={
2932
'data': [
30-
"shapely", "geojson", "numpy", "rasterio", "PILLOW", "opencv-python",
31-
"typeguard", "tqdm"
33+
"shapely", "geojson", "numpy", "rasterio", "PILLOW",
34+
"opencv-python", "typeguard", "tqdm"
3235
],
3336
},
3437
classifiers=[

0 commit comments

Comments
 (0)