From c92fa347dffcd56001ca59334f528bf8318e7110 Mon Sep 17 00:00:00 2001 From: Derrick Chambers Date: Mon, 10 Aug 2026 11:35:08 +0200 Subject: [PATCH] Fix ty diagnostics from the crossed #833/#845 merges Both PRs passed CI against pre-merge dev, but their combination fails the ty hook: the size-diagnostics block calls get_byte_count on a value ty cannot see is a Quantity there, and _output_dtypes returns through a SeriesGroupBy.apply the stubs type as DataFrame | Series. Narrow the first with an assert on the size-gated path and pin the second to pd.Series where the union arises. --- dascore/utils/chunk_plan.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dascore/utils/chunk_plan.py b/dascore/utils/chunk_plan.py index 94f594567..69728747e 100644 --- a/dascore/utils/chunk_plan.py +++ b/dascore/utils/chunk_plan.py @@ -644,7 +644,11 @@ def _output_dtypes(sub: pd.DataFrame, members: pd.DataFrame) -> pd.Series | None return None by_patch = sub.drop_duplicates("_patch_id").set_index("_patch_id")["_dtype"] grouped = members.groupby("output_id")["_patch_id"] - dtypes = grouped.apply(lambda pids: _combined_dtype(by_patch.reindex(pids))) + # A scalar-returning apply on a SeriesGroupBy is always a Series; the + # stubs cannot see through the lambda and claim DataFrame | Series. + dtypes: pd.Series = grouped.apply( # ty: ignore[invalid-assignment] + lambda pids: _combined_dtype(by_patch.reindex(pids)) + ) # "" is the same not-known sentinel ingest writes; never leave NaN, # which would reach the derived catalog as the string "nan". return dtypes.map(lambda x: "" if x is None else str(x)) @@ -901,6 +905,9 @@ def build_chunk_plan( out_frames.append(outputs) member_frames.append(members) if size_diagnostics: + # Diagnostics are only collected on the size-chunk path, where the + # chunk value is an information Quantity (is_data_size gated). + assert isinstance(value, Quantity) params["size"] = { "requested_bytes": get_byte_count(value), "partitions": tuple(size_diagnostics),