Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate entries when running poetry update --dry-run #3097

Closed
2 of 3 tasks
MarcoGlauser opened this issue Oct 6, 2020 · 4 comments · Fixed by #4660
Closed
2 of 3 tasks

Duplicate entries when running poetry update --dry-run #3097

MarcoGlauser opened this issue Oct 6, 2020 · 4 comments · Fixed by #4660
Labels
area/ux Features and improvements related to the user experience kind/bug Something isn't working as expected

Comments

@MarcoGlauser
Copy link

MarcoGlauser commented Oct 6, 2020

Issue

The command poetry update --dry-run duplicates the output of packages as seen below.
image

I first noticed it in poetry 1.1.0. I could reproduce it on different machines with the attached gist.

@MarcoGlauser MarcoGlauser added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Oct 6, 2020
@abn abn added Good First Issue area/ux Features and improvements related to the user experience and removed status/triage This issue needs to be triaged labels Oct 6, 2020
@ahlaw
Copy link

ahlaw commented Oct 9, 2020

Hi, can I take this issue? I think I found the problem, when the _dry_run attribute is set, the executor writes after passing the _should_write_operation check here and then again inside _do_execute_operation here. _dry_run should be removed from one of those checks.

@abn
Copy link
Member

abn commented Oct 9, 2020

@ahlaw most definitey! Feel free to create a draft PR for this if you want to discuss a solution.

@mmacchia
Copy link
Contributor

mmacchia commented Oct 19, 2021

Hello everyone! I see this is still open, and the issue is still present in the latest version.
Moreover, the corresponding PR was not merged last year. Would it be ok if I give it a go?

branchvincent pushed a commit that referenced this issue Aug 24, 2022
# Pull Request Check List

Resolves: #3097 

<!-- This is just a reminder about the most common mistakes. Please make sure that you tick all *appropriate* boxes.  But please read our [contribution guide](https://python-poetry.org/docs/contributing/) at least once, it will save you unnecessary review cycles! -->

- [x] Added **tests** for changed code. I adapted the test in the `tests/console/commands/plugin/test_remove.py` file to reflect the bug fix.
- [ ] Updated **documentation** for changed code.

<!-- If you have *any* questions to *any* of the points above, just **submit and ask**!  This checklist is here to *help* you, not to deter you from contributing! -->

Apart from running the ci linting steps and pytest locally for both python 3.6 and 3.8, I also tested the code by running
```
docker run --rm -i --entrypoint bash python:3.8 <<EOF
set -e
python -m pip install -q git+https://github.com/mmacchia/poetry.git@issue/3097
python -m poetry new foobar
pushd foobar
sed -i /pytest/d pyproject.toml
python -m poetry add --dry-run pycowsay
python -m poetry run pip list
EOF
```
The corresponding output is:
```
Created package foobar in foobar
/foobar /
Creating virtualenv foobar-lWDpn5M1-py3.8 in /root/.cache/pypoetry/virtualenvs
Using version ^0.0.0.1 for pycowsay

Updating dependencies
Resolving dependencies...

Writing lock file

Package operations: 1 install, 0 updates, 0 removals

  • Installing pycowsay (0.0.0.1)
Package    Version
---------- -------
pip        21.2.4
setuptools 58.1.0
wheel      0.37.0
```
As expected, the command `poetry add --dry-run pycowsay` yielded a single output (` • Installing pycowsay (0.0.0.1)`) and did not add the package to the project (see the output of `poetry run pip list`).

The change in the PR solves the duplication issue because the creation of the console output when `not self._enabled` is taken care of by the boolean output of the`self._should_write_operation(operation)` function.

Please feel free to get in touch if I can help adding more test cases for the `--dry-run` argument or the `_enabled` flag and to add any feedback. I would be happy to improve/clarify the code in this PR.

Co-authored-by: Marco Macchia <[email protected]>
Copy link

github-actions bot commented Mar 1, 2024

This issue 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 github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/ux Features and improvements related to the user experience kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants