You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2023/01/09 18:07:35 UTC

[GitHub] [airflow] bolkedebruin commented on a diff in pull request #28742: Fix serialize() usages in custom JSON encoders

bolkedebruin commented on code in PR #28742:
URL: https://github.com/apache/airflow/pull/28742#discussion_r1064942679


##########
airflow/serialization/serde.py:
##########
@@ -176,11 +189,11 @@ def deserialize(o: T | None, full=True, type_hint: Any = None) -> object:
     if isinstance(o, _primitives):
         return o
 
-    if isinstance(o, _iterables):
+    if isinstance(o, _collections):
         return [deserialize(d) for d in o]
 
     if not isinstance(o, dict):
-        raise TypeError()
+        raise TypeError("not deserializable")

Review Comment:
   It is probably better to explain what type we are getting if we are improving the error message,.



##########
airflow/serialization/serde.py:
##########
@@ -249,23 +262,19 @@ def _convert(old: dict) -> dict:
 
 
 def _match(classname: str) -> bool:
-    for p in _patterns:
-        if p.match(classname):
-            return True
-
-    return False
+    return any(p.match(classname) is not None for p in _patterns)

Review Comment:
   nice!



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org