poetry icon indicating copy to clipboard operation
poetry copied to clipboard

feat: improve operation messages and make them stateful

Open johnslavik opened this issue 1 year ago • 1 comments

Pull Request Check List

  • [x] Added tests for changed code.
  • [ ] Updated documentation for changed code.

This PR proposes more meaningful messages on installation operations:

  • "Writing lock file" was displayed after writing the lock file. Now the message is "Lock file written", but I'm happy to adapt to a different idea that introduces past tense.
    The key is to convey the true state of the lock file; looking at https://github.com/python-poetry/poetry/blob/fe9f85baa1a533eb66cde1ee8f76fcf5386dbae2/src/poetry/installation/installer.py#L350-L354 one could easily observe that the "Writing lock file" message is written if updated_lock is truthy—and can only be after actually completing writing the lock file: https://github.com/python-poetry/poetry/blob/fe9f85baa1a533eb66cde1ee8f76fcf5386dbae2/src/poetry/packages/locker.py#L251-L259 https://github.com/python-poetry/poetry/blob/fe9f85baa1a533eb66cde1ee8f76fcf5386dbae2/src/poetry/packages/locker.py#L309-L313 Where TOMLFile.write() atomically writes to the file.
  • In terminals supporting ANSI output, the "Installing the current project" message shifts to "Installed the current project" when finished.
  • Operation objects were partially stateful (e.g. held the skipped attribute) and now are fully stateful (store the information about whether they are in the done, warning or error state). Different attribute names ideas are welcome.
  • Executor.get_operation_message() was deprecated and polymorphism was utilized in lieu of it. The new implementation was made to be 100% equivalent except that after the relevant operations finish, their messages use past tense in ANSI supporting cases–instead of freezing at "Downgrading" if Update(...).done is True, "Downgraded" is written eventually, etc.
  • Instead of "Removing... (...): Removing..." and similar messages for other job types, one will now read "Removing ... (...): In progress..." as long as the operation is in progress. Other ideas welcome.

Before this can eventually be merged, we need a new GIF in the Poetry readme. @neersighted could you help with that?

johnslavik avatar Mar 27 '24 22:03 johnslavik

I recorded "before and after" with asciinema for poetry add pydantic and poetry remove pydantic commands in the poetry repo. What concerns me is that the operation messages starting with hyphens no longer become MarkDown bullet points. (Ignore the a command and the sync-pre-commit-lock extension).

Before After
before after

johnslavik avatar Mar 27 '24 23:03 johnslavik

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar May 10 '25 00:05 github-actions[bot]