From c35a38bb9e9b23c796f601ec359744ba6865e3bc Mon Sep 17 00:00:00 2001 From: Lindsey Gray Date: Mon, 15 Jan 2024 17:34:44 -0600 Subject: [PATCH 1/2] better typing in manipulations --- src/coffea/dataset_tools/manipulations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coffea/dataset_tools/manipulations.py b/src/coffea/dataset_tools/manipulations.py index 263e9781d..c1ad15a77 100644 --- a/src/coffea/dataset_tools/manipulations.py +++ b/src/coffea/dataset_tools/manipulations.py @@ -109,7 +109,7 @@ def _default_filter(name_and_file): def filter_files( fileset: FilesetSpec, - thefilter: Callable[[str, CoffeaFileSpec], bool] = _default_filter, + thefilter: Callable[[tuple[str, CoffeaFileSpec]], bool] = _default_filter, ) -> FilesetSpec: """ Modify the input dataset so that only the files of each dataset that pass the filter remain. @@ -117,7 +117,7 @@ def filter_files( ---------- fileset: FilesetSpec The set of datasets to be sliced. - thefilter: Callable[[CoffeaFileSpec], bool], default filters empty files + thefilter: Callable[[tuple[str, CoffeaFileSpec]], bool], default filters empty files How to filter the files in the each dataset. Returns From f313670361b44a9c61c1a2ce587a173ac1e65d91 Mon Sep 17 00:00:00 2001 From: Lindsey Gray Date: Mon, 15 Jan 2024 17:53:47 -0600 Subject: [PATCH 2/2] better naming of variables in _default_filter --- src/coffea/dataset_tools/manipulations.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coffea/dataset_tools/manipulations.py b/src/coffea/dataset_tools/manipulations.py index c1ad15a77..94612b5be 100644 --- a/src/coffea/dataset_tools/manipulations.py +++ b/src/coffea/dataset_tools/manipulations.py @@ -99,9 +99,9 @@ def slice_files(fileset: FilesetSpec, theslice: Any = slice(None)) -> FilesetSpe return out -def _default_filter(name_and_file): - name, a_file = name_and_file - thesteps = a_file["steps"] +def _default_filter(name_and_spec): + name, spec = name_and_spec + thesteps = spec["steps"] return thesteps is not None and ( len(thesteps) > 1 or (thesteps[0][1] - thesteps[0][0]) != 0 )