From 90c5f45a1f07a2dd954f36d7713fbbbd840bcfb5 Mon Sep 17 00:00:00 2001 From: Aaron Wagener Date: Tue, 24 Oct 2023 15:50:53 -0500 Subject: [PATCH] Options: have as_dict return set values as lists to reduce JSON footprint (#2354) * Options: return set values as lists to reduce JSON footprint * sorted() Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> --------- Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> --- Options.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Options.py b/Options.py index d9ddfc2e..9b4f9d99 100644 --- a/Options.py +++ b/Options.py @@ -950,7 +950,10 @@ class CommonOptions(metaclass=OptionsMetaProperty): else: raise ValueError(f"{casing} is invalid casing for as_dict. " "Valid names are 'snake', 'camel', 'pascal', 'kebab'.") - option_results[display_name] = getattr(self, option_name).value + value = getattr(self, option_name).value + if isinstance(value, set): + value = sorted(value) + option_results[display_name] = value else: raise ValueError(f"{option_name} not found in {tuple(type(self).type_hints)}") return option_results