GeezerVison is showing github.com — gh-111681: Fix doctests in `typing.rst` and remove unused imports by sobolevn · Pull Request #111682 · python/cpython
Conversation
sobolevn
commented
Nov 3, 2023
•
edited by hugovk
Loading
Uh oh!
There was an error while loading. Please reload this page.
Without globs it would fail:
» ./python.exe -m test test_typing
Using random seed: 1924694082
0:00:00 load avg: 1.95 Run 1 test sequentially
0:00:00 load avg: 1.95 [1/1] test_typing
test test_typing failed -- Traceback (most recent call last):
File "/Users/sobolev/Desktop/cpython2/Lib/doctest.py", line 2263, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for typing.rst
File "/Users/sobolev/Desktop/cpython2/Doc/library/typing.rst", line 0
----------------------------------------------------------------------
File "/Users/sobolev/Desktop/cpython2/Doc/library/typing.rst", line 648, in typing.rst
Failed example:
Z[int, [dict, float]]
Expected:
__main__.Z[int, [dict, float]]
Got:
Z[int, [dict, float]]
----------------------------------------------------------------------
File "/Users/sobolev/Desktop/cpython2/Doc/library/typing.rst", line 669, in typing.rst
Failed example:
X[int, str]
Expected:
__main__.X[[int, str]]
Got:
X[[int, str]]
----------------------------------------------------------------------
File "/Users/sobolev/Desktop/cpython2/Doc/library/typing.rst", line 671, in typing.rst
Failed example:
X[[int, str]]
Expected:
__main__.X[[int, str]]
Got:
X[[int, str]]
----------------------------------------------------------------------
File "/Users/sobolev/Desktop/cpython2/Doc/library/typing.rst", line 1996, in typing.rst
Failed example:
Alias.__module__
Expected:
'__main__'
Got nothing
📚 Documentation preview 📚: https://cpython-previews--111682.org.readthedocs.build/
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
AlexWaygood
commented
Nov 3, 2023
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
I think we already run these doctests via Sphinx in CI. If there are certain doctests that aren't being run via that CI job, then I think we should investigate why that is, rather than running the entire doctest suite twice in CI
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
AlexWaygood
commented
Nov 3, 2023
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+651
to
+652
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't actually doctested, I don't think, since you don't have the .. doctest:: directive above this block. (I've just pushed to your branch to add it.)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
sobolevn
Nov 3, 2023
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a doctest, clearly:
» ./python.exe -m doctest Doc/library/typing.rst
**********************************************************************
File "Doc/library/typing.rst", line 651, in typing.rst
Failed example:
1 + 2
Expected:
4
Got:
3
**********************************************************************
1 items had failures:
1 of 48 in typing.rst
***Test Failed*** 1 failures.
It works the same way with and without .. doctest::.
The problem might that Sphinx does not recognize doctests without this directive, but this is clearly a Sphinx's own issue.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that was what I meant, sorry for not being clear: that it wouldn't be picked up by sphinx's doctest job :)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might need to use doctest_test_doctest_blocks from https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html
We can try enabling that, sure, but that should be a separate issue/PR. This PR is about fixing broken doctests in typing.rst, not changing the way we determine in CI which doctests should be run. The majority of these that need to be tested already are tested, using the .. doctest:: directive.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
.. doctest::
|
|
|
|
|
|
>>> from typing import ParamSpec
|
|
|
>>> from typing import ParamSpec, get_origin
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind the change you're making here. But the reason why this doesn't currently fail when Sphinx runs our doctests in CI is because of this, which is run before every doctest block:
|
.. testsetup:: * |
|
|
|
import typing |
|
from dataclasses import dataclass |
|
from typing import * |
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.
Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
It seems like the current CI job is not broken at all
It might not be broken, it just allows a lot of broken doctests in.
I think that regular doctests must always work, not just some sub-selection of them.
Because what happens in reality is that a lot of code blocks / example do not have .. doctest directive and they become outdated, maintainers do not notice it, users get upset.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
AlexWaygood
commented
Nov 3, 2023
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Because what happens in reality is that a lot of code blocks / example do not have .. doctest directive and they become outdated, maintainers do not notice it, users get upset.
I agree this situation is suboptimal. But that makes me think that we should do one of the following two things:
- Get rid of the current doctest job in CI, try to make sure all doctests in all the docs are run via unittest
- Explore using
doctest_test_doctest_blocks, as you suggested in gh-111681: Fix doctests in typing.rst and remove unused imports #111682 (comment), so that all doctest blocks in all the docs are tested by Sphinx by default.
It makes no sense to me to do what this PR currently proposes: run most of the doctests in typing.rst twice in CI.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
sobolevn
commented
Nov 3, 2023
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Yes, I agree. I will convert it to a very minimalistic one: just remove unused imports and fix doctests a bit, without adding new tests to the suite.
|
AlexWaygood reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
sobolevn
changed the title
gh-111681: Fix doctests in typing.rst and run it in CI
gh-111681: Fix doctests in typing.rst and remove unused imports
Nov 3, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks @sobolevn for the PR, and @AlexWaygood for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Sorry, @sobolevn and @AlexWaygood, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker ccc8caa8587103c4ccf617ba106cef63344504dd 3.12
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Sorry, @sobolevn and @AlexWaygood, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker ccc8caa8587103c4ccf617ba106cef63344504dd 3.11
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@sobolevn, can I leave the backports with you? :)
|
sobolevn reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Will do, I will also create a new issue about our CI + doctest.
|
AlexWaygood reacted with heart emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️
Hi! The buildbot AMD64 Windows11 Bigmem 3.x has failed when building commit ccc8caa.
What do you need to do:
- Don't panic.
- Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
- Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/1079/builds/2658) and take a look at the build logs.
- Check if the failure is related to this commit (ccc8caa) or if it is a false positive.
- If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.
You can take a look at the buildbot page here:
https://buildbot.python.org/all/#builders/1079/builds/2658
Summary of the results of the build (if available):
==
Click to see traceback logs
remote: Enumerating objects: 8, done.
remote: Counting objects: 12% (1/8)
remote: Counting objects: 25% (2/8)
remote: Counting objects: 37% (3/8)
remote: Counting objects: 50% (4/8)
remote: Counting objects: 62% (5/8)
remote: Counting objects: 75% (6/8)
remote: Counting objects: 87% (7/8)
remote: Counting objects: 100% (8/8)
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 12% (1/8)
remote: Compressing objects: 25% (2/8)
remote: Compressing objects: 37% (3/8)
remote: Compressing objects: 50% (4/8)
remote: Compressing objects: 62% (5/8)
remote: Compressing objects: 75% (6/8)
remote: Compressing objects: 87% (7/8)
remote: Compressing objects: 100% (8/8)
remote: Compressing objects: 100% (8/8), done.
remote: Total 8 (delta 0), reused 1 (delta 0), pack-reused 0
From https://github.com/python/cpython
* branch main -> FETCH_HEAD
Note: switching to 'ccc8caa8587103c4ccf617ba106cef63344504dd'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at ccc8caa858 gh-111681: minor fixes to typing doctests; remove unused imports in `test_typing` (#111682)
Switched to and reset branch 'main'
Could Not Find R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\*.pyc
The system cannot find the file specified.
Could Not Find R:\buildarea\3.x.ambv-bb-win11.bigmem\build\PCbuild\python*.zip
Could Not Find R:\buildarea\3.x.ambv-bb-win11.bigmem\build\PCbuild\python*.zip
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️
Hi! The buildbot x86-64 macOS 3.x has failed when building commit ccc8caa.
What do you need to do:
- Don't panic.
- Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
- Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/366/builds/5809) and take a look at the build logs.
- Check if the failure is related to this commit (ccc8caa) or if it is a false positive.
- If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.
You can take a look at the buildbot page here:
https://buildbot.python.org/all/#builders/366/builds/5809
Summary of the results of the build (if available):
==
Click to see traceback logs
Note: switching to 'ccc8caa8587103c4ccf617ba106cef63344504dd'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at ccc8caa858 gh-111681: minor fixes to typing doctests; remove unused imports in `test_typing` (#111682)
Switched to and reset branch 'main'
configure: WARNING: pkg-config is missing. Some dependencies may not be detected correctly.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: libpython3.13d.a(dynamic_annotations.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: libpython3.13d.a(pymath.o) has no symbols
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: -undefined dynamic_lookup may not work with chained fixups
make: *** [buildbottest] Error 3
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
aisk
pushed a commit
to aisk/cpython
that referenced
this pull request
Feb 11, 2024
Reviewers
gvanrossum
Awaiting requested review from gvanrossum
JelleZijlstra
Awaiting requested review from JelleZijlstra
JelleZijlstra is a code owner
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|