From 21f172aca558195793b5c24aa64ab1ad619677c8 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Thu, 25 Jun 2026 00:31:57 +0300 Subject: [PATCH] gh-105895: Add `match` and `case` doc to `help()` (GH-152113) (cherry picked from commit 1d55b3778c1c31549c5f914fcc451db4a3dcc501) Co-authored-by: sobolevn Co-authored-by: dzherb Co-authored-by: Stan Ulbrych --- Doc/tools/extensions/pydoc_topics.py | 1 + Lib/pydoc.py | 4 +++- Lib/test/test_pydoc/test_pydoc.py | 2 +- .../Library/2026-06-24-22-16-35.gh-issue-105895.hRkuEw.rst | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2026-06-24-22-16-35.gh-issue-105895.hRkuEw.rst diff --git a/Doc/tools/extensions/pydoc_topics.py b/Doc/tools/extensions/pydoc_topics.py index 35878e2d1e43e9b..6c30a9c62626fb1 100644 --- a/Doc/tools/extensions/pydoc_topics.py +++ b/Doc/tools/extensions/pydoc_topics.py @@ -70,6 +70,7 @@ "lambda", "lazy", "lists", + "match", "naming", "nonlocal", "numbers", diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 497cc7d90a42456..1076caefd93d5e1 100644 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1829,6 +1829,7 @@ class Helper: 'async': ('async', ''), 'await': ('await', ''), 'break': ('break', 'while for'), + 'case': 'match', 'class': ('class', 'CLASSES SPECIALMETHODS'), 'continue': ('continue', 'while for'), 'def': ('function', ''), @@ -1840,12 +1841,13 @@ class Helper: 'for': ('for', 'break continue while'), 'from': 'import', 'global': ('global', 'nonlocal NAMESPACES'), - 'if': ('if', 'TRUTHVALUE'), + 'if': ('if', 'TRUTHVALUE match'), 'import': ('import', 'MODULES'), 'in': ('in', 'SEQUENCEMETHODS'), 'is': 'COMPARISON', 'lambda': ('lambda', 'FUNCTIONS'), 'lazy': ('lazy', 'MODULES'), + 'match': ('match', 'if'), 'nonlocal': ('nonlocal', 'global NAMESPACES'), 'not': 'BOOLEAN', 'or': 'BOOLEAN', diff --git a/Lib/test/test_pydoc/test_pydoc.py b/Lib/test/test_pydoc/test_pydoc.py index 5cd26923f75c311..c840212938de921 100644 --- a/Lib/test/test_pydoc/test_pydoc.py +++ b/Lib/test/test_pydoc/test_pydoc.py @@ -2172,7 +2172,7 @@ def mock_getline(prompt): def test_keywords(self): self.assertEqual(sorted(pydoc.Helper.keywords), - sorted(keyword.kwlist + ['lazy'])) + sorted(keyword.kwlist + ['case', 'match', 'lazy'])) def test_interact_empty_line_continues(self): # gh-138568: test pressing Enter without input should continue in help session diff --git a/Misc/NEWS.d/next/Library/2026-06-24-22-16-35.gh-issue-105895.hRkuEw.rst b/Misc/NEWS.d/next/Library/2026-06-24-22-16-35.gh-issue-105895.hRkuEw.rst new file mode 100644 index 000000000000000..c69e6fa7d14f4dc --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-06-24-22-16-35.gh-issue-105895.hRkuEw.rst @@ -0,0 +1,2 @@ +Add :keyword:`match` and :keyword:`case` to the list of supported topics by +:func:`help`.