From 5cec021c841cb4b8726a27449dc379c4a4568bed Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 24 Jun 2026 22:17:19 +0300 Subject: [PATCH 1/2] gh-105895: Add `match` and `case` to `help()` Originally published in https://github.com/python/cpython/pull/132784 Co-authored-by: dzherb --- Doc/tools/extensions/pydoc_topics.py | 2 ++ 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, 8 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 35878e2d1e43e9..dbf076a56de65e 100644 --- a/Doc/tools/extensions/pydoc_topics.py +++ b/Doc/tools/extensions/pydoc_topics.py @@ -40,6 +40,7 @@ "break", "callable-types", "calls", + "case", "class", "comparisons", "compound", @@ -70,6 +71,7 @@ "lambda", "lazy", "lists", + "match", "naming", "nonlocal", "numbers", diff --git a/Lib/pydoc.py b/Lib/pydoc.py index fe42592530c2cf..041ee26c791f36 100644 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1844,6 +1844,7 @@ class Helper: 'async': ('async', ''), 'await': ('await', ''), 'break': ('break', 'while for'), + 'case': 'match', 'class': ('class', 'CLASSES SPECIALMETHODS'), 'continue': ('continue', 'while for'), 'def': ('function', ''), @@ -1855,12 +1856,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 5543c664528e6c..25f94c4c740e1e 100644 --- a/Lib/test/test_pydoc/test_pydoc.py +++ b/Lib/test/test_pydoc/test_pydoc.py @@ -2237,7 +2237,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 00000000000000..cfb6ae1d9c9ee6 --- /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 support topics by +:func:`help`. From 0f2e2311bdfb9e879ac81125b5281a7ed1c83872 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 24 Jun 2026 23:56:22 +0300 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Stan Ulbrych --- Doc/tools/extensions/pydoc_topics.py | 1 - .../next/Library/2026-06-24-22-16-35.gh-issue-105895.hRkuEw.rst | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Doc/tools/extensions/pydoc_topics.py b/Doc/tools/extensions/pydoc_topics.py index dbf076a56de65e..6c30a9c62626fb 100644 --- a/Doc/tools/extensions/pydoc_topics.py +++ b/Doc/tools/extensions/pydoc_topics.py @@ -40,7 +40,6 @@ "break", "callable-types", "calls", - "case", "class", "comparisons", "compound", 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 index cfb6ae1d9c9ee6..c69e6fa7d14f4d 100644 --- 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 @@ -1,2 +1,2 @@ -Add :keyword:`match` and :keyword:`case` to the list of support topics by +Add :keyword:`match` and :keyword:`case` to the list of supported topics by :func:`help`.