From cee9efc0ab3068e05a853ffb27c82ada869372fe Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 30 Jul 2024 01:51:27 +0100 Subject: [PATCH] Use ``classmethod`` for a class method --- CHANGES.rst | 2 ++ sphinx/highlighting.py | 2 +- tests/test_highlighting.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) 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):