Exclude tests/test_ipunittest.py from trailing-whitespace pre-commit hook#15322
Merged
Conversation
The fixture docstrings in this file intentionally end continuation prompt lines (e.g. " ....: ") with trailing whitespace, which IPython's ipdoctest parser requires to recognize a blank continuation line. The pre-commit-hooks "trailing-whitespace" hook doesn't honor "# fmt: off" and strips that whitespace, which is what broke the pre-commit autoupdate PR (#15321): once darker/pre-commit-hooks were bumped and the autofix commit ran, the hook rewrote this file and tests/test_ipunittest.py failed to collect with "ValueError: line N of the docstring ... lacks blank after ...".
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
PR #15321 (pre-commit.ci autoupdate) has widespread CI failures across the
test_extra,oldest-deps,3.14tand3.15-devjobs that look unrelated to the version bumps it contains, but they're actually a direct side effect of the autoupdate.The failure is:
Root cause:
tests/test_ipunittest.pycontains@ipdoctest/@ipdocstringfixtures whose continuation-prompt lines (....:) intentionally end in trailing whitespace — IPython'sipdoctestparser (_check_prompt_blankinIPython/testing/plugin/ipdoctest.py) requires that whitespace to recognize a blank continuation line. The file has a# fmt: offcomment to protect it fromblack/darkerreformatting, but that comment has no effect on thepre-commit-hookstrailing-whitespacehook.When pre-commit.ci ran its autofix as part of #15321's autoupdate,
trailing-whitespacestripped that intentional trailing whitespace, which breaks doctest collection forFoo.ipdt_methodon every job except the one Python/OS combo that happens not to hit that autofixed line count difference... in practice it broke it everywhere except the twotest (ubuntu-latest, 3.13)/test (macos-14, 3.13)jobs that apparently ran before pre-commit.ci pushed its autofix commit onto the PR branch.Fix
Add an
excludefortests/test_ipunittest.pyon thetrailing-whitespacehook in.pre-commit-config.yaml, so futurepre-commit run --all-filesinvocations (including pre-commit.ci's) leave this fixture's meaningful trailing whitespace alone.Verified locally:
pre-commit run trailing-whitespace --files tests/test_ipunittest.pynow reports "no files to check / Skipped".pytest tests/test_ipunittest.pypasses (5 passed).Test plan
pytest tests/test_ipunittest.pypasses locallypre-commit run trailing-whitespace --files tests/test_ipunittest.pyskips the excluded fileGenerated by Claude Code