Skip to content

Reuse parsed value enclosures by default#593

Draft
claell wants to merge 1 commit into
sciunto-org:mainfrom
claell:feature/592-reuse-value-enclosures
Draft

Reuse parsed value enclosures by default#593
claell wants to merge 1 commit into
sciunto-org:mainfrom
claell:feature/592-reuse-value-enclosures

Conversation

@claell

@claell claell commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Reuse parsed quote, brace, and safe bare enclosure styles in the default writer.
  • Preserve established quote/brace style when users edit field values.
  • Fall back to braces if a formerly bare integer is edited to ordinary text.
  • Keep braces as the default for new programmatic values without parser metadata.
  • Extend the enclosure matrix so stale no-enclosing metadata cannot authorize unsafe text.

Closes #592.

Validation

  • Complete enclosure suite under warnings-as-errors: 928 passed, 2 skipped.
  • Complete upstream suite: 2,588 passed, 4 skipped, with the four existing deprecation warnings in tests/test_entrypoint.py.
  • Complete pre-commit hook suite: passed.

The safety rule also turns eight formerly skipped matrix combinations into executable assertions because ordinary text with stale bare metadata now has an unambiguous enclosed result.

Review note

This changes default formatting but preserves semantics and reduces unrelated diffs. Callers that require uniform braces can still configure AddEnclosingMiddleware(reuse_previous_enclosing=False, ...) explicitly.

The edited-bare guard is important: blindly applying no-enclosing parser metadata after a value changes can emit invalid BibTeX. An explicit field.enclosing = "no-enclosing" demand still takes precedence for callers intentionally supplying a valid bare expression.

AI assistance

This pull request was prepared with ChatGPT Codex using GPT-5.6 Sol with high reasoning effort. Codex assisted with default-policy analysis, unsafe-edit discovery, matrix refinement, and validation. Automated validation is not a substitute for maintainer review.

* Preserve quote, brace, and safe bare styles during ordinary writes.
* Fall back to braces when edits make stale bare metadata unsafe.
* Retain brace defaults for values created without parser metadata.
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.

Reuse parsed value enclosures by default

1 participant