diff --git a/sdks/python/apache_beam/typehints/batch.py b/sdks/python/apache_beam/typehints/batch.py index b193c590bec4..5e18e7488084 100644 --- a/sdks/python/apache_beam/typehints/batch.py +++ b/sdks/python/apache_beam/typehints/batch.py @@ -188,7 +188,9 @@ def from_typehints(element_type, if not isinstance(element_type, NumpyTypeHint.NumpyTypeConstraint): try: element_type = NumpyArray[element_type, ()] - except TypeError as e: + # NumPy 2.4.6+ can also raise a value error if given a dtype that cannot + # be converted into a numpy dtype. + except (TypeError, ValueError) as e: raise TypeError("Element type is not a dtype") from e if not isinstance(batch_type, NumpyTypeHint.NumpyTypeConstraint):