diff --git a/Lib/pydoc.py b/Lib/pydoc.py index a586d35866b038f..e1efe8fc0a1b631 100644 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -2028,12 +2028,12 @@ class Helper: topics = { 'TYPES': ('types', 'STRINGS UNICODE NUMBERS SEQUENCES MAPPINGS ' - 'FUNCTIONS CLASSES MODULES FILES inspect'), + 'FUNCTIONS CLASSES MODULES inspect'), 'STRINGS': ('strings', 'str UNICODE SEQUENCES STRINGMETHODS ' 'FORMATTING TYPES'), 'STRINGMETHODS': ('string-methods', 'STRINGS FORMATTING'), 'FORMATTING': ('formatstrings', 'OPERATORS'), - 'UNICODE': ('strings', 'encodings unicode SEQUENCES STRINGMETHODS ' + 'UNICODE': ('strings', 'encodings SEQUENCES STRINGMETHODS ' 'FORMATTING TYPES'), 'NUMBERS': ('numbers', 'INTEGER FLOAT COMPLEX TYPES'), 'INTEGER': ('integers', 'int range'), diff --git a/Lib/test/test_pydoc/test_pydoc.py b/Lib/test/test_pydoc/test_pydoc.py index a63530c29058275..552b0c7d0759498 100644 --- a/Lib/test/test_pydoc/test_pydoc.py +++ b/Lib/test/test_pydoc/test_pydoc.py @@ -2294,6 +2294,19 @@ def test_keywords(self): self.assertEqual(sorted(pydoc.Helper.keywords), sorted(keyword.kwlist + ['case', 'match', 'lazy'])) + def test_related_topics(self): + # Every related help topic and alias must be something help() can + # document. + for name, target in (*pydoc.Helper.topics.items(), + *pydoc.Helper.keywords.items()): + if isinstance(target, str): + target = ('', target) + for xref in target[1].split(): + with self.subTest(topic=name, xref=xref): + buf = StringIO() + pydoc.Helper(output=buf).help(xref) + self.assertNotIn('No help entry found', buf.getvalue()) + def test_symbols(self): # gh-161414 for symbol in pydoc.Helper.symbols: diff --git a/Misc/NEWS.d/next/Library/2026-11-05-12-00-24.gh-issue-161415.NJhrAR.rst b/Misc/NEWS.d/next/Library/2026-11-05-12-00-24.gh-issue-161415.NJhrAR.rst new file mode 100644 index 000000000000000..22cc4665c253dde --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-05-12-00-24.gh-issue-161415.NJhrAR.rst @@ -0,0 +1,3 @@ +Remove ``FILES`` and ``unicode`` from the related help topics listed by +:func:`help` for the ``TYPES`` and ``UNICODE`` topics. Neither exists in +Python 3, so asking for help on them failed.