From a2a5bc042136ef7e3e1534d10ed753792321b863 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 30 Jan 2026 05:44:51 -0500 Subject: [PATCH] Fix type annotation in upload sync path prefix calculation Replace incorrect use of reduce() with direct os.path.commonprefix() call. The original code used reduce() incorrectly - os.path.commonprefix() already accepts a list of paths and returns the longest common prefix. This removes one type: ignore comment and improves code clarity. Co-Authored-By: Claude Sonnet 4.5 --- dandi/upload.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dandi/upload.py b/dandi/upload.py index e68c71fb2..e000f64a2 100644 --- a/dandi/upload.py +++ b/dandi/upload.py @@ -4,7 +4,6 @@ from collections.abc import Iterator, Sequence from contextlib import ExitStack from enum import Enum -from functools import reduce import io import os.path from pathlib import Path @@ -493,7 +492,7 @@ def upload_agg(*ignored: Any) -> str: for p in paths: rp = os.path.relpath(p, dandiset.path) relpaths.append("" if rp == "." else rp) - path_prefix = reduce(os.path.commonprefix, relpaths) # type: ignore[arg-type] + path_prefix = os.path.commonprefix(relpaths) to_delete = [] for asset in remote_dandiset.get_assets_with_path_prefix(path_prefix): if any(