kaxil commented on code in PR #70974:
URL: https://github.com/apache/airflow/pull/70974#discussion_r3702658200


##########
task-sdk/src/airflow/sdk/serde/__init__.py:
##########
@@ -285,7 +285,11 @@ def serialize(o: object, depth: int = 0) -> U | None:
         dct[DATA] = serialize(data, depth + 1)
         return dct
 
-    raise TypeError(f"cannot serialize object of type {cls}")
+    raise TypeError(
+        f"cannot serialize object of type {cls}. Give it a `serialize()` 
method (and a matching "
+        "`deserialize(data, version)`), or decorate the class with @dataclass 
or @attr.define. "

Review Comment:
   serde calls this unbound off the class (`getattr(cls, 
"deserialize")(deserialize(value), version)`), so a plain `def 
deserialize(self, data, version)` written from this message serializes fine and 
then dies on read with a confusing missing-argument error. The docs example 
uses `@staticmethod` and the message in `deserialize()` below says classmethod, 
both of which work. Maybe say staticmethod in both messages to match the docs.



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

Reply via email to