Skip to content

Commit

Permalink
feat: Remove try-catch from is_numpy_array() (unnecessary)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmsquire committed Apr 26, 2022
1 parent 1fa5e07 commit 731876f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions serde/numpy.py
Expand Up @@ -51,13 +51,10 @@ def deserialize_numpy_scalar(arg):
return f"{fullname(arg.type)}({arg.data})"

def is_numpy_array(typ) -> bool:
try:
origin = get_origin(typ)
if origin is not None:
typ = origin
return typ is np.ndarray
except TypeError:
return False
origin = get_origin(typ)
if origin is not None:
typ = origin
return typ is np.ndarray

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

0 comments on commit 731876f

Please sign in to comment.