Skip to content

fix: write project TOML files atomically - #3871

Merged
frostming merged 1 commit into
mainfrom
fix/atomic-project-file-writes
Aug 31, 2026
Merged

fix: write project TOML files atomically#3871
frostming merged 1 commit into
mainfrom
fix/atomic-project-file-writes

Conversation

@lodyai

@lodyai lodyai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Pull Request Checklist

  • A news fragment is added in news/ describing what is new.
  • Test cases added for changed code.

Describe what you have changed in this PR.

  • Write project TOML content through atomic_open_for_write so interrupted writes do not truncate pyproject.toml or lockfiles.
  • Preserve the line separator detected by tomlkit and disable implicit newline translation while writing the temporary file.
  • Cover pyproject.toml, pdm.lock, pylock.toml, and CRLF preservation with regression tests.

Fixes #3870.

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.79%. Comparing base (b6acd0e) to head (81297cb).

Files with missing lines Patch % Lines
src/pdm/project/toml_file.py 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3871      +/-   ##
==========================================
- Coverage   88.79%   88.79%   -0.01%     
==========================================
  Files         120      120              
  Lines       13322    13330       +8     
  Branches     2265     2267       +2     
==========================================
+ Hits        11829    11836       +7     
  Misses        931      931              
- Partials      562      563       +1     
Flag Coverage Δ
unittests 88.67% <90.90%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@frostming
frostming merged commit 4abfe39 into main Aug 31, 2026
24 of 25 checks passed
@frostming
frostming deleted the fix/atomic-project-file-writes branch August 31, 2026 02:34
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.

Interrupted project file writes can truncate pyproject.toml or pdm.lock to zero bytes

1 participant