Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/toml_fmt_common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def _handle_one(info: TOMLFormatter[T], config: _Config[T]) -> bool:
return changed

if before != formatted and not config.check:
config.toml_filename.write_text(formatted, encoding="utf-8")
config.toml_filename.write_text(formatted, encoding="utf-8", newline="\n")
if config.no_print_diff:
return changed
try:
Expand Down
11 changes: 11 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,14 @@ def test_dumb_path_no_write(capsys: pytest.CaptureFixture[str], tmp_path: Path)
out, err = capsys.readouterr()
assert "\ntoml-fmt-common: error: argument inputs: cannot write path\n" in err
assert not out


def test_writes_lf_line_endings(tmp_path: Path) -> None:
dumb = tmp_path / "dumb.toml"
dumb.write_text("")

run(Dumb(), ["E", str(dumb)])

raw = dumb.read_bytes()
assert b"\r\n" not in raw
assert b"\n" in raw