Skip to content

Commit 731876f

Browse files
committed
feat: Remove try-catch from is_numpy_array() (unnecessary)
1 parent 1fa5e07 commit 731876f

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

serde/numpy.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,10 @@ def deserialize_numpy_scalar(arg):
5151
return f"{fullname(arg.type)}({arg.data})"
5252

5353
def is_numpy_array(typ) -> bool:
54-
try:
55-
origin = get_origin(typ)
56-
if origin is not None:
57-
typ = origin
58-
return typ is np.ndarray
59-
except TypeError:
60-
return False
54+
origin = get_origin(typ)
55+
if origin is not None:
56+
typ = origin
57+
return typ is np.ndarray
6158

6259
def serialize_numpy_array(arg) -> str:
6360
return f"{arg.varname}.tolist()"

0 commit comments

Comments
 (0)