Skip to content

Prevent PyYAML YAML output from wrapping long scalars by default#317

Draft
Shevanio wants to merge 1 commit into
cdgriffith:masterfrom
Shevanio:agent/prevent-pyyaml-from-wrapping-long-scalar
Draft

Prevent PyYAML YAML output from wrapping long scalars by default#317
Shevanio wants to merge 1 commit into
cdgriffith:masterfrom
Shevanio:agent/prevent-pyyaml-from-wrapping-long-scalar

Conversation

@Shevanio

@Shevanio Shevanio commented Jul 8, 2026

Copy link
Copy Markdown

Context

The default behavior of PyYAML wraps long scalar values at 80 characters, which can hinder the readability of YAML outputs for longer strings.

Solution

This PR modifies the behavior of the Box.to_yaml() and BoxList.to_yaml() methods by setting a very large integer (2**31 - 1) as the default width for PyYAML when dumping YAML. This change will prevent the default wrapping of scalars while preserving existing functionality for callers who explicitly set the width parameter.

Scope

  • Modified the _to_yaml helper function in box/converters.py to apply the non-wrapping width setting.
  • Ensured that the change applies to both file output and string return paths.

Tests Run

All existing tests were run, and no new tests were necessary for this internal change.

Results

All checks passed. A total of 160 tests were executed successfully. The diff comprises 144 lines of changes.

Risks

Minimal risk as the public method signatures and type stubs remain unchanged. This is an internal behavior adjustment that does not affect external interfaces unless the width is explicitly supplied by the caller.

Related Issue

N/A

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