gemini-code-assist[bot] commented on code in PR #18870:
URL: https://github.com/apache/tvm/pull/18870#discussion_r2883733206


##########
python/tvm/relax/expr.py:
##########
@@ -712,10 +712,12 @@ def __len__(self):
 
 
 def make_shape(shape: list[Any] | tuple[Any, ...]) -> ShapeExpr:
-    if isinstance(shape, list | tuple):
+    if isinstance(shape, (list, tuple)):

Review Comment:
   ![critical](https://www.gstatic.com/codereviewagent/critical.svg)
   
   The change from `list | tuple` to `(list, tuple)` for the `isinstance` check 
is a critical fix. The `|` operator for type unions in `isinstance` is not 
supported in Python versions prior to 3.10, and even in 3.10+, the correct 
syntax for checking multiple types is to pass a tuple of types. This ensures 
broader compatibility and correct behavior.



##########
python/tvm/relax/expr.py:
##########
@@ -712,10 +712,12 @@ def __len__(self):
 
 
 def make_shape(shape: list[Any] | tuple[Any, ...]) -> ShapeExpr:
-    if isinstance(shape, list | tuple):
+    if isinstance(shape, (list, tuple)):
         return ShapeExpr(shape)
-    raise ValueError("Wrong type")
-
+    raise TypeError(
+        "make_shape expects a list or tuple of shape values, "
+        f"but received type {type(shape).__name__}"
+    )

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Changing the exception type from `ValueError` to `TypeError` is more 
appropriate here, as the issue is specifically about the type of the input 
`shape`. The improved error message also provides much clearer guidance to the 
user, indicating the expected types and the type actually received.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to