Repository navigation
fix(transforms): join and sentence_repair treat a non-string var as absent - #405
Merged
Merged
Conversation
Three cases put a number or `true` in place of `before` and `after`. They fail on main: `.strip()` raises, `run` returns the clip unchanged, and no rule fires. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2 Signed-off-by: Nathan Zylbersztejn <[email protected]>
`ctx.vars.input.before` and `after` are read only when they are strings. Before this, a number or a boolean there made `.strip()` raise, `run` caught it, and the clip was neither joined nor unstopped. The `# type: ignore[arg-type]` on the `join` call goes: mypy now sees `str | None`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2 Signed-off-by: Nathan Zylbersztejn <[email protected]>
…protected `score.py` reads a new case key, `protected:`, the raw value the `vocabulary` stage published, in place of `written:`. Two cases set it to 7 and to `true`. They fail on main: `.split` raises in `written_by_vocabulary`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2 Signed-off-by: Nathan Zylbersztejn <[email protected]>
… string `written_by_vocabulary` now reads `protected` only when it is a string, as it already does `before` and `judged`. Before this, a non-empty number or `true` there made `.split` raise, `run` caught it, every rule was lost, and `declined` said `failed: ...`. The `# type: ignore[union-attr]` goes: mypy now sees `str`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2 Signed-off-by: Nathan Zylbersztejn <[email protected]>
|
Automatic reviews are disabled for this repository. Configure in Code Review Settings. |
Owner
Author
|
Local CodeRabbit review ( |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 20 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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.
joinandsentence_repairnow treat a var that is not a string as absent. Before this, a user stage that published a number ortruewhere they expect text made each script raise. The script caught it and gave up:joinleft the clip unjoined, andsentence_repairlost every rule and reporteddeclined: failed: .... These are the two bugsmypy --strictfound in #404. Their# type: ignorelines go. When the vars are strings, both scripts give the same output as before.Review the two small hunks in
join.pyrun()andsentence_repair.pywritten_by_vocabulary(). The rest is test cases.What failed, and what it does now: same envelope, main against this branch
Each script is fed one invented envelope on stdin. Python 3.9.6 and 3.13.7 print the same.
joininput.before = 7i think you should. try this,applied: ""i think you should try this,applied: "stop at a pause"joininput.after = true,beforea stringthe cache should be smaller.,applied: ""The cache should be smaller.,applied: "line start"joinThe cache should be smaller.,line startsentence_repairvocabulary.protected = 7Noteskept,declined: "failed: 'int' object has no attribute 'split'"notes,capitals: 1,declined: ""sentence_repairvocabulary.protected = truedeclined: "failed: 'bool' object has no attribute 'split'"notes,capitals: 1,declined: ""sentence_repairvocabulary.protected = "Notes"NoteskeptSwift publishes both vars as strings, so the app does not reach either bug today.
vocabularyis a reserved stage name, so only theinputcase can come from a user stage.Tests: five new cases fail on main and pass here
Commits are ordered test first, then fix, for each script.
join/cases.yaml: three cases withbefore: 7,before: truewithafter: true, and a stringbeforewithafter: 7. On mainscripts/check-join.shgives 46/49 ("right answer, wrong rule", nothing applied). Here it gives 49/49.sentence_repair/cases.yaml: two cases withprotected: 7andprotected: true.score.pyreads the newprotected:case key as the raw value thevocabularystage published, in place ofwritten:. On mainscore.pystops withAttributeError: 'int' object has no attribute 'split'. Here it gives 48/48. Both cases reuse inputs already inenvelopes.json, so nothing is recorded again.Old cases print the same lines as main in both scorers. The only diff is the new lines and the totals.
Why the output is the same when the vars are strings, and why no live gate
The change is a type guard and nothing else.
join: for astrorNone,beforeandafterkeep their value, sojoin()andunstopped()get the same arguments.sentence_repair: for astr, the loop runsprotected.split("; ")exactly as before. ForNone,"",0orFalse, main split"", which yields no token, and the branch skips the loop. Same set.Checked on the binary. Main's release binary and this branch's ran
--pipelineon four invented texts, one after the other. The pipeline is a stubinputstage that publishesbefore/afterfrom a file, thensentence_repair, thenjoin. Runs: plain (parse: false,readings: false) and with the parse and readings (--warm). With string vars or no vars, all 20 runs (12 plain, 8 with the parse and readings) give byte-identical stdout with--vars, once the.mstiming lines are removed. With a number ortrueunderinput, 11 of 12 runs differ, and only injoin's lines: main applies nothing, the branch appliesline startorclip stop dropped. The 12th is a two-sentence clip thatjoinleaves alone on both sides.No live gate: no Swift changes, and no output changes for any string input.
The other type: ignore lines hide no bug
Two remain, both in
join.py, both[call-overload]at lines 195 and 424. mypy types the{}fallback in(envelope.get("ctx") or {})asdict[Never, Never]. At run time{}.get(...)returnsNoneand the nextor {}handles it. Line 195 also checksisinstance(published, dict)and passes the value throughstr(...).sentence_repair.pyhad only the one ignore this PR removes.Checks: main and branch print the same
check-envelope,check-python-runner,check-sentence-case,check-schema,check-catalogue,check-default-config,check-upgrade-config,check-pipeline-configandcheck-transform-foldersall pass on both sides. Their output is the same once temp paths are removed. With the models in a scratch home,check-bare-capital(39/39),check-french-boundary(27/27) andcheck-sentence-joinalso print the same on both sides.check-joingoes from 46/46 to 49/49. Not run locally:check-python-types.sh, because mypy is not installed here (CI runs it and passes);check-grammar, which needs Ollama and does not read either script. Local CodeRabbit review: 0 findings.🤖 Generated with Claude Code
https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2