From c983b99542713b871e0bf89c3ac3c4aec69bbfc9 Mon Sep 17 00:00:00 2001 From: johnslavik Date: Tue, 22 Sep 2026 15:43:48 +0200 Subject: [PATCH] Include doctest discovery in PEP 846 --- peps/pep-0846.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/peps/pep-0846.rst b/peps/pep-0846.rst index ac723cfc3c0..14beea5d8fa 100644 --- a/peps/pep-0846.rst +++ b/peps/pep-0846.rst @@ -238,9 +238,10 @@ For the opening example, the reference implementation displays: See help(typing.TypeAliasType) for the full type alias interface. -This PEP does not add automatic discovery of type alias docstrings to -:py:mod:`doctest`. Supporting this would require a separate change to its -discovery rules. +:py:mod:`doctest` discovers type alias docstrings in modules and classes, +and accepts type alias objects in a module's ``__test__`` dictionary. +As with functions and classes, aliases imported from other modules are +excluded from automatic discovery. Discovery does not evaluate alias values. Rationale @@ -306,6 +307,7 @@ A CPython prototype is available at these revisions: * `Compiler, runtime, and AST support `_. * `pydoc support `_. +* `doctest discovery `_. The grammar rule for the :py:keyword:`type` statement gains an optional group that parses the expression statement on the following logical line. @@ -395,3 +397,4 @@ CC0-1.0-Universal license, whichever is more permissive. .. _Issue: https://github.com/python/cpython/issues/156925 .. _Compiler: https://github.com/johnslavik/cpython/commit/a807d9bd68eaf2243b4869a4c2213c705ec18206 .. _Pydoc: https://github.com/johnslavik/cpython/commit/67f572e4cadc0eeef9f1d8cbd22404622ccc2c92 +.. _Doctest: https://github.com/johnslavik/cpython/commit/25044689382307876f310c23fd94e5662aab22b1