python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.51k stars 2.26k forks source link

poetry show -o / poetry show -l output loses expected functionality if line overruns the terminal width #2880

Open mikenerone opened 4 years ago

mikenerone commented 4 years ago

Issue

Adding a URL dependency breaks the functionality of poetry show -l and poetry show -o, causing them both to have name-only output similar to bare poetry show.

mikenerone@mnerone ~/dev/superapp $ poetry show -l  # Starting with working normally
atomicwrites   1.4.0  1.4.0  Atomic file writes.
attrs          20.1.0 20.1.0 Classes Without Boilerplate
colorama       0.4.3  0.4.3  Cross-platform colored terminal text.
more-itertools 8.5.0  8.5.0  More routines for operating on iterables, beyond itertools
packaging      20.4   20.4   Core utilities for Python packages
pluggy         0.13.1 0.13.1 plugin and hook calling mechanisms for python
py             1.9.0  1.9.0  library with cross-python path, ini-parsing, io, code, log facilities
pyparsing      2.4.7  2.4.7  Python parsing module
pytest         5.4.3  6.0.1  pytest: simple powerful testing with Python
six            1.15.0 1.15.0 Python 2 and 3 compatibility utilities
wcwidth        0.2.5  0.2.5  Measures the displayed width of unicode strings in a terminal
mikenerone@mnerone ~/dev/superapp $ poetry show -o
pytest 5.4.3 6.0.1 pytest: simple powerful testing with Python
mikenerone@mnerone ~/dev/superapp $ poetry add pycowsay  # Add a normal dep continues to work
Using version ^0.0.0 for pycowsay

Updating dependencies
Resolving dependencies... (0.1s)

Writing lock file

Package operations: 1 install, 0 updates, 0 removals

  • Installing pycowsay (0.0.0.1)
mikenerone@mnerone ~/dev/superapp $ poetry show -l
atomicwrites   1.4.0   1.4.0   Atomic file writes.
attrs          20.1.0  20.1.0  Classes Without Boilerplate
colorama       0.4.3   0.4.3   Cross-platform colored terminal text.
more-itertools 8.5.0   8.5.0   More routines for operating on iterables, beyond itertools
packaging      20.4    20.4    Core utilities for Python packages
pluggy         0.13.1  0.13.1  plugin and hook calling mechanisms for python
py             1.9.0   1.9.0   library with cross-python path, ini-parsing, io, code, log facilities
pycowsay       0.0.0.1 0.0.0.1
pyparsing      2.4.7   2.4.7   Python parsing module
pytest         5.4.3   6.0.1   pytest: simple powerful testing with Python
six            1.15.0  1.15.0  Python 2 and 3 compatibility utilities
wcwidth        0.2.5   0.2.5   Measures the displayed width of unicode strings in a terminal
mikenerone@mnerone ~/dev/superapp $ poetry show -o
pytest 5.4.3 6.0.1 pytest: simple powerful testing with Python
mikenerone@mnerone ~/dev/superapp $ poetry remove pycowsay
Updating dependencies
Resolving dependencies... (0.1s)

Writing lock file

Package operations: 0 installs, 0 updates, 1 removal

  • Removing pycowsay (0.0.0.1)
mikenerone@mnerone ~/dev/superapp $ poetry add https://files.pythonhosted.org/packages/ee/a6/8fb6d569c59e0e3622f10ae39594cbc57f8e5f36517291e221bd156002ef/pycowsay-0.0.0.1-py3-none-any.whl  # But add a URL dep breaks show -l/-o output

Updating dependencies
Resolving dependencies... (0.2s)

Writing lock file

Package operations: 1 install, 0 updates, 0 removals

  • Installing pycowsay (0.0.0.1 https://files.pythonhosted.org/packages/ee/a6/8fb6d569c59e0e3622f10ae39594cbc57f8e5f36517291e221bd156002ef/pycowsay-0.0.0.1-py3-none-any.whl)
mikenerone@mnerone ~/dev/superapp $ poetry show -l
atomicwrites
attrs
colorama
more-itertools
packaging
pluggy
py
pycowsay
pyparsing
pytest
six
wcwidth
mikenerone@mnerone ~/dev/superapp $ poetry show -o
pycowsay
pytest
mikenerone commented 4 years ago

It turns out the cause of this is poetry attempting some dynamic formatting, wherein the full_pretty_version of any locked package (which includes that long URL in the above case) makes the output line too long for the terminal width. In this case, poetry drops all of the version information for all packages along with it. IMO, this is very surprising, and is throwing out the baby with the bathwater, as the user is specifically calling for version details. I would suggest at least including the "not-full" pretty_version of the locked dep, which would leave out the URL, along with the latest pretty_version.

martinka commented 8 months ago

I hit this recently and would add that not only is it surprising it makes the output unpredictable for scripting. I hit it without the -l or -o flags just poetry show --without dev for example

eiriklid commented 6 months ago

Posting here as #8907 was closed as probable duplicate.

My issue where resolved by running stty cols 200. (In my case the cuttoff seem to be at 143)