]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.15] gh-105895: Add `match` and `case` doc to `help()` (GH-152113) (#152126)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 24 Jun 2026 22:02:21 +0000 (00:02 +0200)
committerGitHub <noreply@github.com>
Wed, 24 Jun 2026 22:02:21 +0000 (22:02 +0000)
gh-105895: Add `match` and `case` doc to `help()` (GH-152113)
(cherry picked from commit 1d55b3778c1c31549c5f914fcc451db4a3dcc501)

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: dzherb <zherbin.dima@yandex.ru>
Co-authored-by: Stan Ulbrych <stan@python.org>
Doc/tools/extensions/pydoc_topics.py
Lib/pydoc.py
Lib/test/test_pydoc/test_pydoc.py
Misc/NEWS.d/next/Library/2026-06-24-22-16-35.gh-issue-105895.hRkuEw.rst [new file with mode: 0644]

index 35878e2d1e43e9baf5cfa839b1d5ebbe9a8fc6d6..6c30a9c62626fb1b6dbb7b5a88c1c0921274b4c9 100644 (file)
@@ -70,6 +70,7 @@ _PYDOC_TOPIC_LABELS: Sequence[str] = sorted({
     "lambda",
     "lazy",
     "lists",
+    "match",
     "naming",
     "nonlocal",
     "numbers",
index 497cc7d90a42456d1d3dbe5f58d03e809aed62a9..1076caefd93d5e188d242cc60de7c08d91aea408 100644 (file)
@@ -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',
index 5cd26923f75c311e0fda2493d428a0aebcb5d71e..c840212938de921cacdfbe36951578f96567df25 100644 (file)
@@ -2172,7 +2172,7 @@ class TestHelper(unittest.TestCase):
 
     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 (file)
index 0000000..c69e6fa
--- /dev/null
@@ -0,0 +1,2 @@
+Add :keyword:`match` and :keyword:`case` to the list of supported topics by
+:func:`help`.