Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Doc/tools/extensions/pydoc_topics.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"integers",
"lambda",
"lists",
"match",
"naming",
"nonlocal",
"numbers",
Expand Down
8 changes: 5 additions & 3 deletions Lib/pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,7 @@ class Helper:
# in pydoc_data/topics.py.
#
# CAUTION: if you change one of these dictionaries, be sure to adapt the
# list of needed labels in Doc/tools/extensions/pyspecific.py and
# list of needed labels in Doc/tools/extensions/pydoc_topics.py and
# regenerate the pydoc_data/topics.py file by running
# make pydoc-topics
# in Doc/ and copying the output file into the Lib/ directory.
Expand All @@ -1832,22 +1832,24 @@ class Helper:
'async': ('async', ''),
'await': ('await', ''),
'break': ('break', 'while for'),
'case': 'match',
'class': ('class', 'CLASSES SPECIALMETHODS'),
'continue': ('continue', 'while for'),
'def': ('function', ''),
'del': ('del', 'BASICMETHODS'),
'elif': 'if',
'else': ('else', 'while for'),
'else': ('else', 'if elif match while for'),
'except': 'try',
'finally': 'try',
'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'),
'match': ('match', 'if'),
'nonlocal': ('nonlocal', 'global NAMESPACES'),
'not': 'BOOLEAN',
'or': 'BOOLEAN',
Expand Down
13 changes: 10 additions & 3 deletions Lib/test/test_pydoc/test_pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2118,9 +2118,16 @@ def test_url_requests(self):


class TestHelper(unittest.TestCase):
def test_keywords(self):
self.assertEqual(sorted(pydoc.Helper.keywords),
sorted(keyword.kwlist))
def test_keywords_are_sorted(self):
self.assertEqual(
sorted(pydoc.Helper.keywords),
list(pydoc.Helper.keywords),
)

def test_keywords_in_grammar(self):
all_keywords = set(keyword.kwlist) | set(keyword.softkwlist)
for kw in pydoc.Helper.keywords:
self.assertIn(kw, all_keywords)


class PydocWithMetaClasses(unittest.TestCase):
Expand Down
Loading