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


##########
airflow-core/src/airflow/serialization/serializers/numpy.py:
##########
@@ -69,7 +70,7 @@ def serialize(o: object) -> tuple[U, str, int, bool]:
     ):
         return int(o), name, __version__, True
 
-    if isinstance(o, np.bool_):
+    if hasattr(np, "bool") and isinstance(o, np.bool) or isinstance(o, 
np.bool_):

Review Comment:
   What fails exactly?
   
   numpy1:
   ```python
   >>> import numpy as np
   >>> x = np.bool_(1)
   >>> if hasattr(np, "bool") and isinstance(x, np.bool) or isinstance(x, 
np.bool_):
   ...     print("Yes")
   <python-input-6>:1: FutureWarning: In the future `np.bool` will be defined 
as the corresponding NumPy scalar.
   Yes
   ```
   
   (Slow connection here)



##########
airflow-core/src/airflow/serialization/serializers/numpy.py:
##########
@@ -82,9 +83,8 @@ def deserialize(cls: type, version: int, data: str) -> Any:
     if version > __version__:
         raise TypeError("serialized version is newer than class version")
 
-    allowed_deserialize_classes = [import_string(classname) for classname in 
deserializers]
-
-    if cls not in allowed_deserialize_classes:
-        raise TypeError(f"unsupported {qualname(cls)} found for numpy 
deserialization")
+    name = qualname(cls)
+    if name not in deserializers:

Review Comment:
   It is redundant. The deserializer will only be invoked when `serde` finds it 
in deserializers. This was added in the PR of PyDantic support and should not 
have been there. Let's remove it.



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