Skip to content

Change the default formatting of YAML emitted by tmt#4338

Merged
happz merged 2 commits intomainfrom
yaml-indent-bug
Apr 14, 2026
Merged

Change the default formatting of YAML emitted by tmt#4338
happz merged 2 commits intomainfrom
yaml-indent-bug

Conversation

@happz
Copy link
Copy Markdown
Contributor

@happz happz commented Nov 18, 2025

By setting mapping, sequence, and offset formatting hints for the YAML dumper, the produced YAML incorrectly handles multiline strings starting with an empty line, and export of collection items under tmt * export.

After some experimenting, there seem to be no silver bullet ticking all boxes WRT YAML formatting, but resorting to setting just sequence=2 seems to produce a reasonably formatted YAML.

Note that this does not affect YAML - or fmf - accepted by tmt, only YAML/fmf files written by tmt.

Fixes #3432

Pull Request Checklist

  • implement the feature
  • extend the test coverage

@happz happz added the bug Something isn't working label Nov 18, 2025
@happz happz added this to planning Nov 18, 2025
@github-project-automation github-project-automation bot moved this to backlog in planning Nov 18, 2025
@happz happz moved this from backlog to implement in planning Nov 18, 2025
@happz happz added the status | blocked The merging of PR is blocked on some other issue label Nov 19, 2025
@happz
Copy link
Copy Markdown
Contributor Author

happz commented Nov 19, 2025

Blocked by #4334

@happz happz force-pushed the to-yaml-refactoring branch from 6d5a39d to 0f1f547 Compare December 1, 2025 17:15
@happz happz force-pushed the to-yaml-refactoring branch 2 times, most recently from ee1cd5c to 0e90113 Compare January 8, 2026 12:04
@psss psss force-pushed the to-yaml-refactoring branch from 0e90113 to 337d62d Compare January 13, 2026 11:42
@happz happz force-pushed the to-yaml-refactoring branch from 337d62d to 5fa60ad Compare January 14, 2026 08:02
@thrix thrix force-pushed the to-yaml-refactoring branch from 5fa60ad to 917714d Compare January 14, 2026 13:14
Base automatically changed from to-yaml-refactoring to main January 14, 2026 16:33
@happz happz force-pushed the yaml-indent-bug branch from 375d798 to 3cb08c6 Compare March 19, 2026 08:59
@happz happz added ci | full test Pull request is ready for the full test execution and removed status | blocked The merging of PR is blocked on some other issue labels Mar 19, 2026
@happz happz marked this pull request as ready for review March 19, 2026 09:03
@happz happz force-pushed the yaml-indent-bug branch 2 times, most recently from e1cc042 to 76e10d1 Compare March 26, 2026 13:46
@happz happz moved this from implement to review in planning Mar 26, 2026
@happz happz force-pushed the yaml-indent-bug branch from 76e10d1 to dc902b1 Compare March 31, 2026 16:49
Copy link
Copy Markdown
Member

@psss psss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not able to reproduce the original issue.

Comment thread tmt/utils/__init__.py
@LecrisUT LecrisUT mentioned this pull request Apr 9, 2026
2 tasks
@LecrisUT LecrisUT added the status | blocking other work An important pull request, blocking other pull requests or issues label Apr 9, 2026
Copy link
Copy Markdown
Member

@LecrisUT LecrisUT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for me, it is at least consistent with #4712. I just realized that

The C based emitter doesn’t have the fine control, distinguishing between block mappings and sequences. Do only use the pure Python versions of the dumper if you want to have that sort of control.

🙃

@happz happz moved this from review to merge in planning Apr 13, 2026
happz added 2 commits April 13, 2026 23:53
By setting `mapping`, `sequence`, and `offset` formatting hints for the
YAML dumper, the produced YAML incorrectly handles multiline strings
starting with an empty line, and export of collection items under `tmt *
export`.

After some experimenting, there seem to be no silver bullet ticking
all boxes WRT YAML formatting, but resorting to setting just
`sequence=2` seems to produce a reasonably formatted YAML.

Note that this does not affect YAML - or fmf - accepted by tmt, only
YAML/fmf files written by tmt.

Fixes #3432
@happz happz force-pushed the yaml-indent-bug branch from dc902b1 to 50a802e Compare April 13, 2026 21:53
@happz happz merged commit 229d67e into main Apr 14, 2026
33 checks passed
@happz happz deleted the yaml-indent-bug branch April 14, 2026 06:57
@github-project-automation github-project-automation bot moved this from merge to done in planning Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ci | full test Pull request is ready for the full test execution status | blocking other work An important pull request, blocking other pull requests or issues

Projects

Status: done

Development

Successfully merging this pull request may close these issues.

YAML export indents multiline strings with block indentation indicator way too much

4 participants