Skip to content

typing.rst contains failing doctests #111681

Closed as not planned
Closed as not planned

Description

@sobolevn

Bug report

» ./python.exe -m doctest Doc/library/typing.rst
**********************************************************************
File "Doc/library/typing.rst", line 1959, in typing.rst
Failed example:
    get_origin(P.args) is P
Exception raised:
    Traceback (most recent call last):
      File "/Users/sobolev/Desktop/cpython2/Lib/doctest.py", line 1374, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest typing.rst[15]>", line 1, in <module>
        get_origin(P.args) is P
        ^^^^^^^^^^
    NameError: name 'get_origin' is not defined
**********************************************************************
File "Doc/library/typing.rst", line 1961, in typing.rst
Failed example:
    get_origin(P.kwargs) is P
Exception raised:
    Traceback (most recent call last):
      File "/Users/sobolev/Desktop/cpython2/Lib/doctest.py", line 1374, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest typing.rst[16]>", line 1, in <module>
        get_origin(P.kwargs) is P
        ^^^^^^^^^^
    NameError: name 'get_origin' is not defined
**********************************************************************
1 items had failures:
   2 of  47 in typing.rst
***Test Failed*** 2 failures.
                               

My proposal is too:

  1. Fix it
  2. Add a test to test_typing to ensure that doctests pass

Linked PRs

Activity

  1. self-assigned this
    on Nov 3, 2023
  2. added a commit that references this issue on Nov 3, 2023
  3. AlexWaygood commented on Nov 3, 2023

    @AlexWaygood
    Member

    The doctests in typing.rst aren't designed to be run via python -m doctest. They're designed to be run via Sphinx; we have special directives like this, which instruct Sphinx to run blocks of code prior to every doctest, but which wouldn't have any impact if you just ran the doctests via python -m doctest:

    .. testsetup:: *
    import typing
    from dataclasses import dataclass
    from typing import *

  4. added a commit that references this issue on Nov 3, 2023
  5. added 4 commits that reference this issue on Nov 9, 2023
  6. added a commit that references this issue on Feb 11, 2024
  7. added a commit that references this issue on Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

testsTests in the Lib/test dirtopic-typingtype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions