From e5f2f320e0988ca4d649d5d82a02bbb0d452c599 Mon Sep 17 00:00:00 2001 From: Matthew Rocklin Date: Mon, 18 Dec 2023 08:08:49 -0800 Subject: [PATCH] Fixup is_dask_collection test --- dask/base.py | 6 +++++- dask/tests/test_base.py | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dask/base.py b/dask/base.py index f2b8014cc71..fb22932383c 100644 --- a/dask/base.py +++ b/dask/base.py @@ -223,7 +223,11 @@ def is_dask_collection(x) -> bool: else: raise TypeError("Unfamiliar with xarray type", type(x)) else: - return hasattr(x, "__dask_graph__") + return ( + hasattr(x, "__dask_graph__") + and callable(x.__dask_graph__) + and not isinstance(x, type) + ) except (AttributeError, TypeError): return False diff --git a/dask/tests/test_base.py b/dask/tests/test_base.py index d0fc9489c95..b19d4a7130e 100644 --- a/dask/tests/test_base.py +++ b/dask/tests/test_base.py @@ -677,7 +677,6 @@ def __dask_graph__(self): x = delayed(1) + 2 assert is_dask_collection(x) - assert not is_dask_collection(2) assert is_dask_collection(DummyCollection({})) assert not is_dask_collection(DummyCollection)