Repository navigation
fix(lang-python): preserve grouped imports in the oracle - #781
Merged
Merged
Conversation
5 tasks done
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
Report named Python from-imports in the grouped form used by the Language plugin.
The evaluator can compare the original imported names, including aliased names and Unicode source spelling.
Closes #780
Tier
Tier 3 from
cargo xtask risk-tier --base origin/main.The test-oracle guard flags the updated assertion for the former bare-module output.
Task
Fail-first test
python_oracle::the_python_oracle_preserves_names_in_a_from_importran once and failed.The oracle emitted
collectionsinstead offrom collections import Counter.After grouping was fixed, the extended fixture ran once and failed because the AST emitted
Kfor the original nameK. The extended fixture also reproduced two Unicode module keys collapsing into one, and the CR-only fixture exposed an oracle crash. Those cases ran and passed after the follow-up. On Python 3.12.15, the encoding regression ran once and failed withinvalid or missing encoding declarationfor a valid Latin-1 source file. The final six-test group passed on Python 3.12.15.Checks
de599cd72a61560464666c544b5e41c5fd242a03Safety proof
The change preserves the import comparison and its recall and precision thresholds.
The regression asserts the original names, deduplication, relative imports, wildcard imports, and source spelling for an AST-normalized name.
The actual evaluator verified one expected static import, one actual import, and one match.
The adversarial probes confirmed distinct Unicode module spellings, CR-only line endings, and valid Latin-1 cookies on Python 3.12.15. The focused changes preserved oracle error records and thresholds.
Runtime evidence
A one-file Git fixture used
from collections import Counter.Before the fix,
codeint checkexited 0 andcodeint-evalexited 1 with 0/1 matches.After the fix, both exited 0 with 1/1 matches.
The Evaluation HOW-TO documents this comparison.
Risk summary
The Python corpus check compares grouped import names against the plugin.
Incorrect grouping can lower measured recall or precision and fail the corpus job.
Reverting restores the previous oracle output and the reproduced corpus failure.
Recommendation: merge on required CI and a green Python corpus run.
The Owner approved the focused fix.
Gaps