Skip to content

Commit 8bc48a9

Browse files
agoose77drammock
andauthored
FIX: avoid implicit string comparison in Sphinx 7.26 (#1592)
* FIX: avoid implicit string comparison in Sphinx 7.26 * lint --------- Co-authored-by: Daniel McCloy <[email protected]>
1 parent 7bdd4c1 commit 8bc48a9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/pydata_sphinx_theme/__init__.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,20 @@ def _remove_empty_templates(tname):
233233
return True
234234

235235
context[section] = list(filter(_remove_empty_templates, context[section]))
236-
236+
#
237237
# Remove a duplicate entry of the theme CSS. This is because it is in both:
238238
# - theme.conf
239239
# - manually linked in `webpack-macros.html`
240240
if "css_files" in context:
241241
theme_css_name = "_static/styles/pydata-sphinx-theme.css"
242-
if theme_css_name in context["css_files"]:
243-
context["css_files"].remove(theme_css_name)
244-
242+
for i in range(len(context["css_files"])):
243+
asset = context["css_files"][i]
244+
# TODO: eventually the contents of context['css_files'] etc should probably
245+
# only be _CascadingStyleSheet etc. For now, assume mixed with strings.
246+
asset_path = getattr(asset, "filename", str(asset))
247+
if asset_path == theme_css_name:
248+
del context["css_files"][i]
249+
break
245250
# Add links for favicons in the topbar
246251
for favicon in context.get("theme_favicons", []):
247252
icon_type = Path(favicon["href"]).suffix.strip(".")

0 commit comments

Comments
 (0)