Skip to content

Commit

Permalink
fix: packagetype fixer avoid dupl. empty section
Browse files Browse the repository at this point in the history
close: #2577
  • Loading branch information
wey-gu committed Jan 21, 2024
1 parent 01f6a8d commit 9a34e81
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/pdm/cli/commands/fix/fixers.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,17 @@ def check(self) -> bool:
return "package-type" in self.project.pyproject.settings

def fix(self) -> None:
package_type = self.project.pyproject.settings.pop("package-type")
# Copy the project settings
settings = self.project.pyproject.settings.copy()

# Pop the package type and convert it to a distribution type
package_type = settings.pop("package-type")
dist = bool(package_type == "library")
self.project.pyproject.settings["distribution"] = dist
settings["distribution"] = dist

# Update the project settings with the new distribution type
self.project.pyproject._data["tool"].pop("pdm")
self.project.pyproject.settings.update(settings)

# Write the updated settings back to the project
self.project.pyproject.write(False)

0 comments on commit 9a34e81

Please sign in to comment.