Skip to content

Commit 726123f

Browse files
committed
themes: Allow extra fields in META beyond those required.
Previously, the test for theme completeness required an exact match to all required fields; this loosens that restriction to allow additional optional fields. Test updated.
1 parent fa282cd commit 726123f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

tests/config/test_themes.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def test_complete_and_incomplete_themes__bundled_theme_output() -> None:
113113
case({"META": None}, False, id="META_absent"),
114114
case({"META": {}}, False, id="META_empty"),
115115
case({"META": {"pygments": {}}}, False, id="META_pygments_empty"),
116+
case({"META": "extra_field"}, True, id="META_with_extra_field"),
116117
],
117118
)
118119
def test_complete_and_incomplete_themes__single_theme_completeness(
@@ -131,7 +132,7 @@ class FakeTheme:
131132
STYLES = {
132133
style: (FakeColor.COLOR_1, FakeColor.COLOR_2) for style in REQUIRED_STYLES
133134
}
134-
META = {
135+
META: Dict[str, Any] = {
135136
"pygments": {
136137
"styles": None,
137138
"background": None,
@@ -144,6 +145,8 @@ class FakeTheme:
144145
for field, action in missing.items():
145146
if action == "incomplete_style":
146147
setattr(FakeTheme, field, incomplete_style)
148+
elif action == "extra_field":
149+
FakeTheme.META["extra_field"] = 5 # Non-iterable misc data
147150
elif action is None:
148151
delattr(FakeTheme, field)
149152
else:

zulipterminal/config/themes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ def complete_and_incomplete_themes() -> Tuple[List[str], List[str]]:
165165
if getattr(theme, "STYLES", None)
166166
if set(theme.STYLES) == set(REQUIRED_STYLES)
167167
if getattr(theme, "META", None)
168-
if set(theme.META) == set(REQUIRED_META)
169-
for meta, conf in theme.META.items()
170-
if set(conf) == set(REQUIRED_META.get(meta, {}))
168+
if set(theme.META).issuperset(set(REQUIRED_META))
169+
for meta, conf in REQUIRED_META.items()
170+
if set(conf) == set(theme.META.get(meta, {}))
171171
}
172172
incomplete = set(THEMES) - complete
173173
return sorted(complete), sorted(incomplete)

0 commit comments

Comments
 (0)