Fix asset class string interface membership testing

This commit is contained in:
Adam Turner 2023-08-17 17:28:59 +01:00
parent 8512855776
commit 49dc0dd399
2 changed files with 11 additions and 0 deletions

View File

@ -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)
=====================================

View File

@ -36,6 +36,10 @@ class _CascadingStyleSheet:
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 @@ class _JavaScript:
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