Modernize ConftestImportFailure to use the exception chain - #14943
Draft
RonnyPfannschmidt wants to merge 1 commit into
Draft
RonnyPfannschmidt wants to merge 1 commit into
RonnyPfannschmidt wants to merge 1 commit into
Conversation
RonnyPfannschmidt
force-pushed
the
conftest-import-failure-modernize
branch
4 times, most recently
from
August 27, 2026 19:58
c5e0b6b to
3e02d6b
Compare
Give ConftestImportFailure the same shape PluginImportFailure just got: a bare Exception subclass whose argument is the conftest path, with the original error carried by `raise ... from` on __cause__ instead of a hand-rolled `cause` attribute duplicating it. The custom __init__ and __str__ go away; str(e) is the path, which is exactly what the two message consumers want. The `cause` attribute dates to 8.0 (e1074f9), which replaced the old excinfo triplet without deprecation; the class is private to _pytest.config and a code search finds no external consumers, only vendored copies of pytest itself. No user-visible output changes. Co-Authored-By: Claude Fable 5 <ai@anthropic.com> Co-Authored-By: Claude Code <ai@anthropic.com>
RonnyPfannschmidt
force-pushed
the
conftest-import-failure-modernize
branch
from
September 15, 2026 11:34
3e02d6b to
15321ee
Compare
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.
Stacked on #14824 — review only the last commit; the first is that PR.
Gives
ConftestImportFailurethe same shapePluginImportFailuregot in #14824: a bareExceptionsubclass whose argument is the conftest path, with the original error carried byraise ... fromon__cause__instead of a hand-rolledcauseattribute duplicating the chain. The custom__init__and__str__go away;str(e)is the path, which is exactly what both message consumers want.Why this is safe:
causeattribute is young — introduced in 8.0 (e1074f9) replacing the oldexcinfotriplet, without deprecation;_pytest.config(not exported aspytest.*), and a GitHub code search finds no external importers, only vendored copies of pytest itself;print_conftest_import_error, the--help/--versiongrace path,Node._repr_failure_pyunwrapping,--pdbpost-mortem unwrapping,_main) are updated in this PR.No user-visible output changes.
🤖 Written by Claude Code (Claude Fable 5); reviewed and submitted by @RonnyPfannschmidt.