diff --git a/CHANGES.rst b/CHANGES.rst index b94c08f089e..0f39c01cbd7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,8 @@ Release 8.0.2 (in development) Bugs fixed ---------- +* Fix the ``pygments.Formatter.__class_getitem__`` patch. + Patch by Adam Turner. Release 8.0.1 (released Jul 30, 2024) ===================================== diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py index bb2687a2bc8..86bdd234430 100644 --- a/sphinx/highlighting.py +++ b/sphinx/highlighting.py @@ -34,7 +34,7 @@ if tuple(map(int, pygments.__version__.split('.')))[:2] < (2, 18): from pygments.formatter import Formatter # NoQA: F811 - Formatter.__class_getitem__ = lambda cls, name: cls # type: ignore[attr-defined] + Formatter.__class_getitem__ = classmethod(lambda cls, name: cls) # type: ignore[attr-defined] logger = logging.getLogger(__name__) diff --git a/tests/test_highlighting.py b/tests/test_highlighting.py index 1b8c2fbff73..95d0b4513a8 100644 --- a/tests/test_highlighting.py +++ b/tests/test_highlighting.py @@ -11,7 +11,7 @@ if tuple(map(int, pygments.__version__.split('.')))[:2] < (2, 18): from pygments.formatter import Formatter - Formatter.__class_getitem__ = lambda cls, name: cls # type: ignore[attr-defined] + Formatter.__class_getitem__ = classmethod(lambda cls, name: cls) # type: ignore[attr-defined] class MyLexer(RegexLexer):