Skip to content

Use tomlkit to dump updated dependencies#212

Open
CasperWA wants to merge 17 commits intomainfrom
cwa/close-203-serialize-via-tomlkit
Open

Use tomlkit to dump updated dependencies#212
CasperWA wants to merge 17 commits intomainfrom
cwa/close-203-serialize-via-tomlkit

Conversation

@CasperWA
Copy link
Collaborator

Closes #203

Add a new utility function to update the parsed pyproject.toml file in-memory document, which will eventually be dumped (using tomlkit) and written to (overwriting) the pyproject.toml file.
This let's tomlkit handle the serialization (converting the parsed file back to TOML-syntax) and should be more stable than the current implementation using regular expressions.

As a side note, this now only writes to/updates the pyproject.toml file once - at the end of going through all dependencies if no errors occurred.
This is an (improved) change from the existing behaviour, which writes to/updates the pyproject.toml file for each dependency (if necessary) and does not revert changes if an error occurs. The improvement I see here, is that the pyproject.toml file now is only changed if there were no errors, plus the disk is touched only once for writing.

@CasperWA CasperWA requested a review from ajeklund November 11, 2023 00:18
@codecov
Copy link

codecov bot commented Nov 11, 2023

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.29%. Comparing base (52fa1fb) to head (f2077db).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #212      +/-   ##
==========================================
- Coverage   85.30%   85.29%   -0.02%     
==========================================
  Files          12       12              
  Lines         939      945       +6     
==========================================
+ Hits          801      806       +5     
- Misses        138      139       +1     

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Contributor

@ajeklund ajeklund left a comment

Choose a reason for hiding this comment

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

I like this update! Seems like there is a problem with the Windows builds, though.

Partly out of scope-question regarding validation: Does the code check if there are multiple occurrences of a dependency where there should not be? Or will such user error be caught somewhere else?

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.

Serialize via tomlkit in update-deps

2 participants