feat: improve operation messages and make them stateful
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_lockis 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 WhereTOMLFile.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.
Operationobjects were partially stateful (e.g. held theskippedattribute) and now are fully stateful (store the information about whether they are in thedone,warningorerrorstate). 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" ifUpdate(...).doneisTrue, "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?
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 |
|---|---|
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.