[SPARK-54770][PYTHON] Replace dead assert with proper error in _create_converter#56051
Open
shrirangmhalgi wants to merge 1 commit into
Open
[SPARK-54770][PYTHON] Replace dead assert with proper error in _create_converter#56051shrirangmhalgi wants to merge 1 commit into
shrirangmhalgi wants to merge 1 commit into
Conversation
…e_converter The else branch in _create_converter was unreachable (marked pragma: no cover) because _need_converter guards entry and every type it returns True for has a corresponding handler. Replace with a raise at function level that works even with Python -O flag.
89c53bd to
db1e202
Compare
Contributor
Author
|
@gaogaotiantian could you please review the following PR |
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.
What changes were proposed in this pull request?
Replace the unreachable
else: assert Falsebranch inLocalDataToArrowConversion._create_converterwith araise AssertionErrorat function level.Why are the changes needed?
The
elsebranch was dead code (marked# pragma: no cover) because_need_converterguards entry to the function and every type it returns True for has a corresponding handler in the if/elif chain. The bareassert Falseinside anelseis silently disabled by Python's-Oflag. Araiseat function level is always active and serves as a safety net if a new type is added to_need_converterwithout a matching converter branch.Does this PR introduce any user-facing change?
No. The removed code was unreachable.
How was this patch tested?
Existing Arrow test suite (62 tests pass). The changed code path is unreachable by design.
Was this patch authored or co-authored using generative AI tooling?
No