Skip to content

Commit 8e89cec

Browse files
authored
[PLT-1580] Cleaned up typed array (#1858)
1 parent 6528cbc commit 8e89cec

File tree

2 files changed

+4
-29
lines changed

2 files changed

+4
-29
lines changed

libs/labelbox/pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ Changelog = "https://github.com/Labelbox/labelbox-python/blob/develop/libs/label
4646
[project.optional-dependencies]
4747
data = [
4848
"shapely>=2.0.3",
49-
# numpy v2 breaks package since it only supports python >3.9
50-
"numpy>=1.24.4, <2.0.0",
49+
"numpy>=1.25.0",
5150
"pillow>=10.2.0",
5251
"typeguard>=4.1.5",
5352
"imagesize>=1.4.1",
@@ -95,7 +94,7 @@ integration = { cmd = "pytest tests/integration" }
9594
data = { cmd = "pytest tests/data" }
9695
rye-lint = "rye lint"
9796
rye-fmt-check = "rye fmt --check"
98-
MYPYPATH="../lbox-clients/src/"
97+
MYPYPATH = "../lbox-clients/src/"
9998
mypy-lint = "mypy src --pretty --show-error-codes --non-interactive --install-types"
10099
lint = { chain = ["rye-fmt-check", "mypy-lint", "rye-lint"] }
101100
test = { chain = ["lint", "unit", "integration"] }
Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
import sys
2-
from typing import Annotated, Any, Generic, TypeVar
3-
1+
from typing import Generic, TypeVar
42
import numpy as np
5-
from packaging import version
6-
from pydantic import ConfigDict, Field, StringConstraints
73
from pydantic_core import core_schema
84

95
DType = TypeVar("DType")
106
DShape = TypeVar("DShape")
117

128

13-
class _TypedArray(np.ndarray, Generic[DType, DShape]):
9+
class TypedArray(np.ndarray, Generic[DType, DShape]):
1410
@classmethod
1511
def __get_pydantic_core_schema__(
1612
cls, _source_type: type, _model: type
@@ -22,23 +18,3 @@ def validate(cls, val):
2218
if not isinstance(val, np.ndarray):
2319
raise TypeError(f"Expected numpy array. Found {type(val)}")
2420
return val
25-
26-
27-
if version.parse(np.__version__) >= version.parse("1.25.0"):
28-
from typing import GenericAlias
29-
30-
TypedArray = GenericAlias(_TypedArray, (Any, DType))
31-
elif version.parse(np.__version__) >= version.parse("1.23.0"):
32-
from numpy._typing import _GenericAlias
33-
34-
TypedArray = _GenericAlias(_TypedArray, (Any, DType))
35-
elif (
36-
version.parse("1.22.0")
37-
<= version.parse(np.__version__)
38-
< version.parse("1.23.0")
39-
):
40-
from numpy.typing import _GenericAlias
41-
42-
TypedArray = _GenericAlias(_TypedArray, (Any, DType))
43-
else:
44-
TypedArray = _TypedArray[Any, DType]

0 commit comments

Comments
 (0)