fix: preserve inter-document separators regardless of explicit_start - #318
Open
david-hong-invitae wants to merge 2 commits into
Open
fix: preserve inter-document separators regardless of explicit_start#318david-hong-invitae wants to merge 2 commits into
david-hong-invitae wants to merge 2 commits into
Conversation
added 2 commits
August 5, 2026 14:57
…setting - Change explicit_start type from bool to Optional[bool] - Default to None (leave document markers as-is) - Never remove inter-document --- separators (structurally required) - explicit_start=False now only affects the first document marker Fixes lyz-code#274 Fixes lyz-code#307
- Keep explicit_start as bool (default: True), no Optional/None state - explicit_start=False removes leading --- but ALWAYS preserves inter-document --- separators (structurally required for valid YAML) - Remove unused type: ignore comment (fixes mypy CI) - Revert test changes that were for the Optional[bool] approach Fixes lyz-code#274 Fixes lyz-code#307
|
Would |
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
Fixes #274, #307
explicit_start = falsecurrently removes ALL---markers including inter-document separators, producing invalid YAML for multi-document files.Changes
explicit_start = falseno longer removes inter-document---separators. These are structurally required for valid multi-document YAML — removing them merges separate documents into one, breaking the file.Behavior after this fix:
explicit_start: true(default) → adds---to all documents (unchanged)explicit_start: false→ removes leading---from first document, preserves inter-document---separatorsImplementation
In
_ruamel_yaml_fixer, whenexplicit_start=Falsemeans ruyaml won't emit---, we manually inject---\nbetween documents (fori > 0) to keep multi-document YAML valid.Test Plan
explicit_start=Falsesingle-doc: leading---removed ✅explicit_start=Falsemulti-doc: inter-document---preserved ✅explicit_start=Falsemulti-doc (3 docs): all separators preserved ✅explicit_start=True: behavior unchanged ✅type: ignore) ✅