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


##########
python/tvm/ir/expr.py:
##########
@@ -413,11 +413,6 @@ def __init__(
                 raise TypeError("ty must be a Type or primitive dtype string")
         self.__init_handle_by_constructor__(_ffi_api.Var, name, ty, span)
 

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   To preserve backward compatibility for external Python scripts and 
downstream projects that access the `.name_hint` attribute on `Var` objects, we 
should keep `name_hint` as a deprecated property that redirects to `.name`.
   
   ```python
                   raise TypeError("ty must be a Type or primitive dtype 
string")
           self.__init_handle_by_constructor__(_ffi_api.Var, name, ty, span)
   
       @property
       def name_hint(self) -> str:
           """Deprecated alias for name."""
           import warnings
           warnings.warn(
               "name_hint is deprecated, please use name instead",
               DeprecationWarning,
               stacklevel=2,
           )
           return self.name
   ```



##########
tests/python/relax/test_expr.py:
##########
@@ -60,8 +60,12 @@ def test_var() -> None:
 
 
 def test_var_name_keyword_compatibility() -> None:
-    assert tvm.ir.Var(name="primary").name == "primary"
-    assert tvm.ir.Var(name_hint="legacy").name == "legacy"
+    primary = tvm.ir.Var(name="primary")
+    legacy = tvm.ir.Var(name_hint="legacy")
+    assert primary.name == "primary"
+    assert legacy.name == "legacy"
+    assert not hasattr(primary, "name_hint")
+    assert not hasattr(legacy, "name_hint")

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Since we are preserving `name_hint` as a deprecated property for backward 
compatibility, we should assert that `name_hint` is still accessible and 
returns the correct name, rather than asserting it does not exist.
   
   ```suggestion
       assert primary.name_hint == "primary"
       assert legacy.name_hint == "legacy"
   ```



##########
tests/python/relax/test_expr.py:
##########
@@ -102,8 +106,12 @@ def test_dataflow_var() -> None:
 
 
 def test_dataflow_var_name_keyword_compatibility() -> None:
-    assert rx.DataflowVar(name="primary").name == "primary"
-    assert rx.DataflowVar(name_hint="legacy").name == "legacy"
+    primary = rx.DataflowVar(name="primary")
+    legacy = rx.DataflowVar(name_hint="legacy")
+    assert primary.name == "primary"
+    assert legacy.name == "legacy"
+    assert not hasattr(primary, "name_hint")
+    assert not hasattr(legacy, "name_hint")

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Since we are preserving `name_hint` as a deprecated property for backward 
compatibility, we should assert that `name_hint` is still accessible and 
returns the correct name on `DataflowVar` as well.
   
   ```suggestion
       assert primary.name_hint == "primary"
       assert legacy.name_hint == "legacy"
   ```



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