@@ -40,12 +40,14 @@ class FileMeta(TypedDict):
4040
4141def _dt_validate (value : Any ) -> torch .dtype :
4242 if isinstance (value , str ):
43- assert value .startswith ("torch." ), f"dtype { value } should start with torch."
43+ if not value .startswith ("torch." ):
44+ raise ValueError (f"dtype { value } should start with torch." )
4445 try :
4546 value = getattr (torch , value .split ("." )[1 ])
4647 except AttributeError as e :
4748 raise ValueError (f"unknown dtype: { value } " ) from e
48- assert isinstance (value , torch .dtype ), f"dtype { value } should be torch.dtype, got { type (value )} "
49+ if not isinstance (value , torch .dtype ):
50+ raise TypeError (f"dtype { value } should be torch.dtype, got { type (value )} " )
4951 return value
5052
5153
@@ -60,7 +62,8 @@ def _dt_validate(value: Any) -> torch.dtype:
6062def _size_validate (value : Any ) -> torch .Size :
6163 if isinstance (value , list | tuple ):
6264 return torch .Size (value )
63- assert isinstance (value , torch .Size ), f"size { value } should be torch.Size, got { type (value )} "
65+ if not isinstance (value , torch .Size ):
66+ raise TypeError (f"size { value } should be torch.Size, got { type (value )} " )
6467 return value
6568
6669
0 commit comments