Undo update of a module via poetry

Viewed 888

Let's say that I have mistakenly run a poetry update <module> and that I want to undo it:

This was the output of the update command

Updating dependencies
Resolving dependencies... (11.5s)

Writing lock file

Package operations: 0 installs, 2 updates, 0 removals

  • Updating mymodule (1.20.28 -> 1.20.36)
  ...

The way I do it currently is to restore pyproject.toml and poetry.lock to their previous state, before rerunning poetry install

git restore poetry.lock pyproject.toml
poetry install

Installing dependencies from lock file

Package operations: 0 installs, 2 updates, 0 removals

  • Updating mymodule (1.20.36 -> 1.20.28)
  ...

However this means that I would lose the changes I had not yet committed on these files (e.g updates on other modules).

Is there a way to do so using only poetry commands ?

I am aware that I could also poetry add mymodule="previous-version" to restore a module to its previous version, however there is no guarantee that its dependencies are also restored to the exact same version as before.

0 Answers
Related