Skip to content

Commit

Permalink
fix: pdm deletes pyproject.toml keys it's not authorized to.
Browse files Browse the repository at this point in the history
Fixes #2666

Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming committed Mar 6, 2024
1 parent f571150 commit 1bf5eb1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/2666.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't modify TOML tables that are not related to PDM.
3 changes: 2 additions & 1 deletion src/pdm/project/project_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def read(self) -> TOMLDocument:

def write(self, show_message: bool = True) -> None:
"""Write the TOMLDocument to the file."""
_remove_empty_tables(self._data)
_remove_empty_tables(self._data.get("project", {}))
_remove_empty_tables(self._data.get("tool", {}).get("pdm", {}))
super().write()
if show_message:
self.ui.echo("Changes are written to [success]pyproject.toml[/].", verbosity=termui.Verbosity.NORMAL)
Expand Down

0 comments on commit 1bf5eb1

Please sign in to comment.