From 12c240dd56a18bb7e25d85f076a6f9f79a58ee2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pa=C4=8Dek?= Date: Fri, 23 Aug 2024 15:23:10 +0200 Subject: [PATCH] Disallow duplicate statement tags in docs I can't think of a use-case for them, so let's simplify code and treat them as an invalid input. (cherry picked from commit 5b832126b32886145028405281a9b1a937dd2434) --- doc/arm/_ext/iscconf.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/doc/arm/_ext/iscconf.py b/doc/arm/_ext/iscconf.py index 32bbec2bf2..1ecd37cb8b 100644 --- a/doc/arm/_ext/iscconf.py +++ b/doc/arm/_ext/iscconf.py @@ -41,18 +41,14 @@ logger = logging.getLogger(__name__) def split_csv(argument, required): argument = argument or "" - values = list(filter(len, (s.strip() for s in argument.split(",")))) - if required and not values: + outlist = list(filter(len, (s.strip() for s in argument.split(",")))) + if required and not outlist: raise ValueError( "a non-empty list required; provide at least one value or remove" " this option" ) - # Order-preserving de-duplication - outlist, seen = list(), set() # pylint: disable=use-list-literal - for value in values: - if value not in seen: - seen.add(value) - outlist.append(value) + if not len(outlist) == len(set(outlist)): + raise ValueError("duplicate value detected") return outlist