Skip to content

Commit 105debd

Browse files
fix: accept any Mapping type for cohorts, not just dict
- Changed isinstance(cohorts, dict) to isinstance(cohorts, Mapping) - Updated error message to reflect Mapping acceptance - Aligns with base_params.cohorts type hint Union[str, Mapping[str, str]] - Resolves Copilot review suggestion
1 parent 53621a8 commit 105debd

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

malariagen_data/anoph/sample_metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,15 +1505,15 @@ def _setup_cohort_queries(
15051505
"""Convenience function to normalise the `cohorts` parameter to a
15061506
dictionary mapping cohort labels to sample metadata queries."""
15071507

1508-
if isinstance(cohorts, dict):
1508+
if isinstance(cohorts, Mapping):
15091509
# User has supplied a custom dictionary mapping cohort identifiers
15101510
# to pandas queries.
15111511
cohort_queries = cohorts
15121512

15131513
else:
15141514
if not isinstance(cohorts, str):
15151515
raise TypeError(
1516-
f"Expected cohorts to be dict or str, "
1516+
f"Expected cohorts to be Mapping or str, "
15171517
f"got {type(cohorts).__name__}: {cohorts!r}"
15181518
)
15191519
# User has supplied a column in the sample metadata.

0 commit comments

Comments
 (0)