From e6932704235dcc14038b607ec551d07ee1ba8fde Mon Sep 17 00:00:00 2001 From: ahmadalguydi Date: Wed, 5 Aug 2026 06:20:56 +0300 Subject: [PATCH] fix: avoid dtype comparison for None report metadata --- meta_tests/test_reporting.py | 16 ++++++++++++++++ reporting.py | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 meta_tests/test_reporting.py diff --git a/meta_tests/test_reporting.py b/meta_tests/test_reporting.py new file mode 100644 index 00000000..bd429351 --- /dev/null +++ b/meta_tests/test_reporting.py @@ -0,0 +1,16 @@ +from array_api_tests.dtype_helpers import EqualityMapping +import reporting + + +class MLXDtype: + def __eq__(self, other): + if other is None: + raise TypeError("MLX dtype equality does not support None") + return self is other + + +def test_to_json_serializable_none_does_not_compare_to_dtypes(monkeypatch): + dtype = MLXDtype() + monkeypatch.setattr(reporting, "dtype_to_name", EqualityMapping([(dtype, "float16")])) + + assert reporting.to_json_serializable(None) is None diff --git a/reporting.py b/reporting.py index 579aa211..8570a7c8 100644 --- a/reporting.py +++ b/reporting.py @@ -17,7 +17,7 @@ raise ImportError("pytest-json-report is required to run the array API tests") def to_json_serializable(o): - if o in dtype_to_name: + if o is not None and o in dtype_to_name: return dtype_to_name[o] if isinstance(o, (BuiltinFunctionType, FunctionType, type)): return o.__name__