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


##########
tests/python/test_object.py:
##########
@@ -102,6 +102,16 @@ def test_opaque_object() -> None:
     assert sys.getrefcount(obj0) == 2
 
 
+def test_opaque_type_error() -> None:
+    obj0 = MyObject("hello")
+    with pytest.raises(TypeError) as e:
+        tvm_ffi.testing.add_one(obj0)  # type: ignore[arg-type]
+    assert (
+        "Mismatched type on argument #0 when calling: `testing.add_one(0: int) 
-> int`. Expected `int` but got `ffi.OpaquePyObject`"
+        in str(e.value)
+    )

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   The long string literal in the assertion makes the line exceed common line 
length recommendations, which can harm readability. To improve maintainability 
and adhere to Python style conventions, it's better to assign the long string 
to a variable before the assertion.[^1]
   
   ```suggestion
       expected_msg = (
           "Mismatched type on argument #0 when calling: `testing.add_one(0: 
int) -> int`. "
           "Expected `int` but got `ffi.OpaquePyObject`"
       )
       assert expected_msg in str(e.value)
   ```
   
   #### Style Guide References
   [^1]: PEP 8 suggests limiting lines of code to 79 characters to improve 
readability. While not a strict rule, it is a widely followed convention in the 
Python community.



-- 
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