Skip to content

Commit

Permalink
#216: Avoid intermittent issue with value already being removed
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Jan 23, 2025
1 parent 7e60328 commit 099d8e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## Unreleased

* Fixed:
* There was an intermittent `ValueError` in PEP 621 mode,
related to trying to remove `"version"` from `project.dynamic`
when it had already been removed.

## v1.7.0 (2025-01-15)

* Added:
Expand Down
8 changes: 5 additions & 3 deletions poetry_dynamic_versioning/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,11 @@ def _apply_version(
if mode == _Mode.Classic:
pyproject["tool"]["poetry"]["version"] = version # type: ignore
elif mode == _Mode.Pep621:
pyproject["project"]["dynamic"].remove("version") # type: ignore
if "version" in pyproject["project"]["dynamic"]: # type: ignore
pyproject["project"]["dynamic"].remove("version") # type: ignore
pyproject["project"]["version"] = version # type: ignore
pyproject["tool"]["poetry"].pop("version") # type: ignore
if "version" in pyproject["tool"]["poetry"]: # type: ignore
pyproject["tool"]["poetry"].pop("version") # type: ignore

# Disable the plugin in case we're building a source distribution,
# which won't have access to the VCS info at install time.
Expand Down Expand Up @@ -727,7 +729,7 @@ def _revert_version(retain: bool = False) -> None:
pyproject["tool"]["poetry"]["version"] = state.original_version # type: ignore
elif state.mode == _Mode.Pep621:
if state.dynamic_array is not None:
pyproject["project"]["dynamic"] = state.dynamic_array
pyproject["project"]["dynamic"] = state.dynamic_array # type: ignore
if "version" in pyproject["project"]: # type: ignore
pyproject["project"].pop("version") # type: ignore
if state.original_version is not None:
Expand Down

0 comments on commit 099d8e4

Please sign in to comment.