junrushao commented on code in PR #411:
URL: https://github.com/apache/tvm-ffi/pull/411#discussion_r2697309759
##########
python/tvm_ffi/dataclasses/_utils.py:
##########
@@ -58,14 +58,13 @@ def type_info_to_cls(
def _add_method(name: str, func: Callable[..., Any]) -> None:
if name == "__ffi_init__":
name = "__c_ffi_init__"
- if name in attrs: # already defined
- return
+ # Allow overriding methods (including from base classes like
Object.__repr__)
+ # by always adding to attrs, which will be used when creating the new
class
func.__module__ = cls.__module__
func.__name__ = name
func.__qualname__ = f"{cls.__qualname__}.{name}"
func.__doc__ = f"Method `{name}` of class `{cls.__qualname__}`"
attrs[name] = func
- setattr(cls, name, func)
Review Comment:
curious why we removed this line?
--
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]