Skip to content

Commit

Permalink
Fix asset class string interface membership testing
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Aug 17, 2023
1 parent 8512855 commit 49dc0dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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)
=====================================
Expand Down
8 changes: 8 additions & 0 deletions sphinx/builders/html/_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 49dc0dd

Please sign in to comment.