From 49dc0dd3999f66f27728b974394585422f10d947 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Thu, 17 Aug 2023 17:28:59 +0100 Subject: [PATCH] Fix asset class string interface membership testing --- CHANGES | 3 +++ sphinx/builders/html/_assets.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGES b/CHANGES index 49782fb4686..1b06ad12506 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,9 @@ Release 7.2.2 (in development) Bugs fixed ---------- +* Fixed membership testing (``in``) for the :py:class:`str` interface + of the asset classes (``_CascadingStyleSheet`` and ``_JavaScript``), + which several extensions relied upon. Release 7.2.1 (released Aug 17, 2023) ===================================== diff --git a/sphinx/builders/html/_assets.py b/sphinx/builders/html/_assets.py index 2d9247007a1..a72c5000bbc 100644 --- a/sphinx/builders/html/_assets.py +++ b/sphinx/builders/html/_assets.py @@ -36,6 +36,10 @@ def __str__(self): f'{attr})') def __eq__(self, other): + if isinstance(other, str): + warnings.warn('The str interface for _CascadingStyleSheet objects is deprecated. ' + 'Use css.filename instead.', RemovedInSphinx90Warning, stacklevel=2) + return self.filename == other if not isinstance(other, _CascadingStyleSheet): return NotImplemented return (self.filename == other.filename @@ -88,6 +92,10 @@ def __str__(self): f'{attr})') def __eq__(self, other): + if isinstance(other, str): + warnings.warn('The str interface for _JavaScript objects is deprecated. ' + 'Use js.filename instead.', RemovedInSphinx90Warning, stacklevel=2) + return self.filename == other if not isinstance(other, _JavaScript): return NotImplemented return (self.filename == other.filename