From 8bc48a9f2b8931b3534debff7d39fcf4a6eaa27b Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Wed, 13 Dec 2023 16:11:40 +0000 Subject: [PATCH] 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 --- src/pydata_sphinx_theme/__init__.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/pydata_sphinx_theme/__init__.py b/src/pydata_sphinx_theme/__init__.py index 2473d4c18..981c889bb 100644 --- a/src/pydata_sphinx_theme/__init__.py +++ b/src/pydata_sphinx_theme/__init__.py @@ -233,15 +233,20 @@ def _remove_empty_templates(tname): return True context[section] = list(filter(_remove_empty_templates, context[section])) - + # # Remove a duplicate entry of the theme CSS. This is because it is in both: # - theme.conf # - manually linked in `webpack-macros.html` if "css_files" in context: theme_css_name = "_static/styles/pydata-sphinx-theme.css" - if theme_css_name in context["css_files"]: - context["css_files"].remove(theme_css_name) - + for i in range(len(context["css_files"])): + asset = context["css_files"][i] + # TODO: eventually the contents of context['css_files'] etc should probably + # only be _CascadingStyleSheet etc. For now, assume mixed with strings. + asset_path = getattr(asset, "filename", str(asset)) + if asset_path == theme_css_name: + del context["css_files"][i] + break # Add links for favicons in the topbar for favicon in context.get("theme_favicons", []): icon_type = Path(favicon["href"]).suffix.strip(".")