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


##########
airflow-core/tests/unit/serialization/test_serde.py:
##########
@@ -408,6 +412,20 @@ def test_serializers_importable_and_str(self):
                 try:
                     import_string(s)
                 except ImportError:
+                    # In NumPy 1.20, `numpy.bool` was deprecated as an alias 
for the built-in `bool`.
+                    # For NumPy versions <= 1.26, attempting to import 
`numpy.bool` raises an ImportError.
+                    # Starting with NumPy 2.0, `numpy.bool` is reintroduced as 
the NumPy scalar type,
+                    # and `numpy.bool_` becomes an alias for `numpy.bool`.
+                    #
+                    # The serializers are loaded lazily at runtime. As a 
result:
+                    # - With NumPy <= 1.26, only `numpy.bool_` is loaded.
+                    # - With NumPy >= 2.0, only `numpy.bool` is loaded.
+                    #
+                    # This test case deliberately attempts to import both 
`numpy.bool` and `numpy.bool_`,
+                    # regardless of the installed NumPy version. Therefore, 
when NumPy <= 1.26 is installed,
+                    # importing `numpy.bool` will raise an ImportError.
+                    if version.parse(metadata.version("numpy")).major < 2 and 
s == "numpy.bool":

Review Comment:
   wondering if it works to add a handle here in the `ImportError` exception to 
check the numpy version and to skip the import of `numpy.bool` with NumPy < 2.
   
   There is a test case in `test_serializers.py` to check for such situation. 
Please let me know if the existing one is not strong enough, and will look into 
it how to enhance it.
   
   
https://github.com/apache/airflow/blob/f5b12db393bde99192fc7e43388f03d1e96f6b5a/airflow-core/tests/unit/serialization/serializers/test_serializers.py#L236
   



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