From 1dfbb14f24c18efc36c139b91d655f3b6661db4d Mon Sep 17 00:00:00 2001 From: Christian Monch Date: Thu, 23 Nov 2023 15:17:04 +0100 Subject: [PATCH 1/2] fix a bug `iter_subproc` This commit fixes a small bug in `iter_subproc.__init__`. The parameter `chunksize` was never used. Instead a constant value was used. The new code passes the value down to `iterable_subprocess`. --- datalad_next/runners/iter_subproc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datalad_next/runners/iter_subproc.py b/datalad_next/runners/iter_subproc.py index d1193a17..9fcfe23d 100644 --- a/datalad_next/runners/iter_subproc.py +++ b/datalad_next/runners/iter_subproc.py @@ -53,5 +53,5 @@ def iter_subproc( return iterable_subprocess( args, tuple() if input is None else input, - chunk_size=COPY_BUFSIZE, + chunk_size=chunk_size, ) From 9b3f3e8f8a6448b8aa0d45b39c3d4e7b84cb36a4 Mon Sep 17 00:00:00 2001 From: Christian Monch Date: Mon, 27 Nov 2023 10:19:38 +0100 Subject: [PATCH 2/2] improve type annotation in `iter_subproc` This commit changes the type of the `input`-parameter of `iter_subproc` from `List[bytes]` to `Iterable[bytes]` (wich includes `List[bytes]`). The previous annotation was unnecessarily restrictive and would lead to type-check errors if an iterator-object, e.g. a result of `iter(...)` was provided as `input`-parameter. --- datalad_next/runners/iter_subproc.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/datalad_next/runners/iter_subproc.py b/datalad_next/runners/iter_subproc.py index 9fcfe23d..5d5bf932 100644 --- a/datalad_next/runners/iter_subproc.py +++ b/datalad_next/runners/iter_subproc.py @@ -1,5 +1,8 @@ from __future__ import annotations -from typing import List +from typing import ( + Iterable, + List, +) from datalad_next.iterable_subprocess.iterable_subprocess \ import iterable_subprocess @@ -11,7 +14,7 @@ def iter_subproc( args: List[str], *, - input: List[bytes] | None = None, + input: Iterable[bytes] | None = None, chunk_size: int = COPY_BUFSIZE, ): """Context manager to communicate with a subprocess using iterables