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


##########
python/tvm_ffi/container.py:
##########
@@ -117,14 +117,12 @@ def __init__(self, input_list: Iterable[T]) -> None:
     def __getitem__(self, idx: SupportsIndex, /) -> T: ...
 
     @overload
-    def __getitem__(self, idx: slice, /) -> Array[T]: ...
+    def __getitem__(self, idx: slice, /) -> Array[T] | list[T]: ...
 
-    def __getitem__(self, idx: SupportsIndex | slice, /) -> T | Array[T]:
+    def __getitem__(self, idx: SupportsIndex | slice, /) -> T | Array[T] | 
list[T]:

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   The type hints for `__getitem__` are slightly inaccurate. Since slicing now 
consistently returns a `list[T]`, the type hints can be made more precise to 
reflect this. This will improve clarity for developers and allow type checkers 
to be more effective.
   
   Specifically:
   - The `@overload` for a slice should indicate a return type of `list[T]`.
   - The main implementation's return type should be `T | list[T]`.
   
   ```suggestion
       def __getitem__(self, idx: slice, /) -> list[T]: ...
   
       def __getitem__(self, idx: SupportsIndex | slice, /) -> T | list[T]:
   ```



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