refactor: convert isinstance chains to match/case (part 4) (#36274)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Asuka Minato <i@asukaminato.eu.org>
This commit is contained in:
Evan
2026-05-31 14:44:17 +00:00
committed by GitHub
co-authored by autofix-ci[bot] Asuka Minato
parent f241ae25be
commit d8571ce965
5 changed files with 215 additions and 189 deletions
+7 -6
View File
@@ -1554,12 +1554,13 @@ class DatasetRetrieval:
case "≥" | ">=":
filters.append(DatasetDocument.doc_metadata[metadata_name].as_float() >= value)
case "in" | "not in":
if isinstance(value, str):
value_list = [v.strip() for v in value.split(",") if v.strip()]
elif isinstance(value, (list, tuple)):
value_list = [str(v) for v in value if v is not None]
else:
value_list = [str(value)] if value is not None else []
match value:
case str():
value_list = [v.strip() for v in value.split(",") if v.strip()]
case list() | tuple():
value_list = [str(v) for v in value if v is not None]
case _:
value_list = [str(value)] if value is not None else []
if not value_list:
# `field in []` is False, `field not in []` is True