Skip to content

YAML I/O: quote with double quotes, matching Prettier's default - #710

Merged
edkerk merged 1 commit into
develop3from
fix/yaml-double-quotes
Aug 28, 2026
Merged

YAML I/O: quote with double quotes, matching Prettier's default#710
edkerk merged 1 commit into
develop3from
fix/yaml-double-quotes

Conversation

@edkerk

@edkerk edkerk commented Aug 28, 2026

Copy link
Copy Markdown
Member

Summary

  • writeYAMLmodel now double-quotes a scalar when quoting is required, instead of single-quoting (which matched ruamel's own default, not a deliberate choice). Matches Prettier's YAML default instead — see raven-gecko-parity discussion; byte-parity with any particular tool's default isn't the actual constraint, only staying importable across RAVEN and raven-toolbox is.
  • readYAMLmodel stripped a wrapping quote pair but never undid the escaping either quote style uses inside it — a latent gap (doubled '' for single-quoted, backslash \/\" for double-quoted) that switching the writer's active quote character exercises for real. Fixed with a proper unescape pass, including a sentinel-based two-step unescape for double quotes so \\\" in the file (an escaped backslash immediately followed by an escaped quote) round-trips correctly rather than being misread.

Test plan

  • tSyntax, tIO — 15 passed, 0 failed, 1 filtered (unrelated missing dependency)
  • Byte-diff against raven-toolbox's write_yaml_model (paired PR) for the same model: identical SHA256
  • Escaping probe: a metabolite name containing both a literal apostrophe and a literal double quote, forced to need quoting — reads back exactly, and survives a further MATLAB read-write-read cycle unchanged
  • Cross-read: raven-toolbox's read_yaml_model on the same probe value recovers the identical text

writeYAMLmodel emitted single quotes when a scalar needed quoting
(matching ruamel's own default, which raven_toolbox's writer was built
against). Switched to double quotes to match Prettier's YAML default
instead, since there's no reason to defer to ruamel's choice over a
more common convention now that byte-parity with either isn't the
constraint --- only staying importable across both toolboxes is.

readYAMLmodel stripped a wrapping quote pair but never undid the
escaping either style uses inside it (doubled '' for a literal
apostrophe in single quotes, backslash escapes for \ and \" in double
quotes) --- a latent gap that switching the active quote character
exercises for real. Fixed: undo whichever style's escaping was used,
with a sentinel-based two-pass unescape for the double-quote case so
an escaped backslash immediately followed by an escaped quote (\\\"
in the file) round-trips correctly.

Verified against a value containing both a literal apostrophe and a
literal double quote, wrapped to force quoting: reads back exactly,
and survives a further MATLAB read-write-read cycle unchanged.
@github-actions

Copy link
Copy Markdown

Function test results

304 tests   277 ✅  59s ⏱️
 25 suites   27 💤
  1 files      0 ❌

Results for commit fc50417.

@edkerk
edkerk merged commit 795b1bb into develop3 Aug 28, 2026
4 checks passed
@edkerk
edkerk deleted the fix/yaml-double-quotes branch August 28, 2026 12:42
edkerk added a commit that referenced this pull request Aug 28, 2026
…lt" (#713)

Reverts the quote-character choice from #710 back to single quotes.
writeYAMLmodel emits single quotes when a scalar needs quoting again,
exactly as before #710 (verified: byte-identical output to the
pre-#710 writer on tutorial/smallYeast.yml, same SHA256).

readYAMLmodel's unescaping keeps handling both quote styles (it
already did, to read files written either way) and #712's list-item
quote-marker-stripping fix is untouched --- that bug affected quoted
list items under either quote convention and isn't specific to which
character is used, so there's no reason to revert it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant