From 8bc99d29ee2206b66b7970878f1aa7190a2f1b87 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Tue, 11 Jun 2024 17:55:11 -0400 Subject: [PATCH] Clarify the documentation generation logic for repeat with dtype Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Jinzhe Zeng --- dargs/dargs.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/dargs/dargs.py b/dargs/dargs.py index 702de15..b9a1c9b 100644 --- a/dargs/dargs.py +++ b/dargs/dargs.py @@ -679,16 +679,13 @@ def gen_doc_body(self, path: list[str] | None = None, **kwargs) -> str: } allowed_types = [] allowed_element = [] - if list in unsubscripted_dtype: - allowed_types.append("list") - allowed_element.append("element") - elif dict in unsubscripted_dtype: - allowed_types.append("dict") - allowed_element.append("key-value pair") - else: - raise ValueError( - "When `repeat` is True, `dtype` should contain `dict` OR `list`." - ) + if list in unsubscripted_dtype or dict in unsubscripted_dtype: + if list in unsubscripted_dtype: + allowed_types.append("list") + allowed_element.append("element") + if dict in unsubscripted_dtype: + allowed_types.append("dict") + allowed_element.append("key-value pair") body_list.append( f"This argument takes a {' or '.join(allowed_types)} with " f"each {' or '.join(allowed_element)} containing the following: \n"