Skip to content

Commit 7dcb98b

Browse files
andresdelfinoclaude
andcommitted
gh-161415: Remove nonexistent related help topics in pydoc
The TYPES topic listed FILES, which was removed from Helper.topics in Python 3.4, and the UNICODE topic listed unicode, the Python 2 built-in type. help() finds no entry for either of them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 288cc2b commit 7dcb98b

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎Lib/pydoc.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,12 +2029,12 @@ class Helper:
20292029

20302030
topics = {
20312031
'TYPES': ('types', 'STRINGS UNICODE NUMBERS SEQUENCES MAPPINGS '
2032-
'FUNCTIONS CLASSES MODULES FILES inspect'),
2032+
'FUNCTIONS CLASSES MODULES inspect'),
20332033
'STRINGS': ('strings', 'str UNICODE SEQUENCES STRINGMETHODS '
20342034
'FORMATTING TYPES'),
20352035
'STRINGMETHODS': ('string-methods', 'STRINGS FORMATTING'),
20362036
'FORMATTING': ('formatstrings', 'OPERATORS'),
2037-
'UNICODE': ('strings', 'encodings unicode SEQUENCES STRINGMETHODS '
2037+
'UNICODE': ('strings', 'encodings SEQUENCES STRINGMETHODS '
20382038
'FORMATTING TYPES'),
20392039
'NUMBERS': ('numbers', 'INTEGER FLOAT COMPLEX TYPES'),
20402040
'INTEGER': ('integers', 'int range'),

‎Lib/test/test_pydoc/test_pydoc.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,6 +2294,20 @@ def test_keywords(self):
22942294
self.assertEqual(sorted(pydoc.Helper.keywords),
22952295
sorted(keyword.kwlist + ['case', 'match', 'lazy']))
22962296

2297+
def test_related_topics(self):
2298+
# Every related help topic must be something help() can document.
2299+
helper = pydoc.Helper
2300+
for name, target in (*helper.topics.items(), *helper.keywords.items()):
2301+
if not isinstance(target, tuple):
2302+
continue
2303+
for xref in target[1].split():
2304+
with self.subTest(topic=name, xref=xref):
2305+
self.assertTrue(xref in helper.topics
2306+
or xref in helper.keywords
2307+
or xref in helper.symbols
2308+
or xref == 'keywords' # the keyword list
2309+
or pydoc.locate(xref) is not None)
2310+
22972311
def test_interact_empty_line_continues(self):
22982312
# gh-138568: test pressing Enter without input should continue in help session
22992313
self.assertEqual(
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove ``FILES`` and ``unicode`` from the related help topics listed by
2+
:func:`help` for the ``TYPES`` and ``UNICODE`` topics. Neither exists in
3+
Python 3, so asking for help on them failed.

0 commit comments

Comments
 (0)