From 1755a718125ef2ea18e9c079ecf1509b7b6be730 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Tue, 18 Jun 2024 07:08:01 -0700 Subject: [PATCH] Python 3.13 fixes (#11185) Signed-off-by: Adam Williamson --- dask/delayed.py | 21 +++++++++++---------- dask/tests/test_utils.py | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/dask/delayed.py b/dask/delayed.py index 1c63a39ef12..350e89fbfa8 100644 --- a/dask/delayed.py +++ b/dask/delayed.py @@ -141,16 +141,17 @@ def unpack_collections(expr): if hasattr(expr, f.name) } replace(expr, **_fields) - except TypeError as e: - raise TypeError( - f"Failed to unpack {typ} instance. " - "Note that using a custom __init__ is not supported." - ) from e - except ValueError as e: - raise ValueError( - f"Failed to unpack {typ} instance. " - "Note that using fields with `init=False` are not supported." - ) from e + except (TypeError, ValueError) as e: + if isinstance(e, ValueError) or "is declared with init=False" in str(e): + raise ValueError( + f"Failed to unpack {typ} instance. " + "Note that using fields with `init=False` are not supported." + ) from e + else: + raise TypeError( + f"Failed to unpack {typ} instance. " + "Note that using a custom __init__ is not supported." + ) from e return (apply, typ, (), (dict, args)), collections if is_namedtuple_instance(expr): diff --git a/dask/tests/test_utils.py b/dask/tests/test_utils.py index 328705f7f26..8aba2b3f380 100644 --- a/dask/tests/test_utils.py +++ b/dask/tests/test_utils.py @@ -600,7 +600,7 @@ def f(a, c): assert "not supported" in b_arg.lower() assert "dask" in b_arg.lower() - assert " extra docstring\n\n" in Zap.f.__doc__ + assert "extra docstring\n\n" in Zap.f.__doc__ @pytest.mark.parametrize(