Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tomlkit to dump updated dependencies #212

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

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.

Copy link

codecov bot commented Nov 11, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.60%. Comparing base (59c6ae8) to head (519b6d8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #212      +/-   ##
==========================================
- Coverage   84.61%   84.60%   -0.01%     
==========================================
  Files          12       12              
  Lines         936      942       +6     
==========================================
+ Hits          792      797       +5     
- Misses        144      145       +1     

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

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