Repository: python-poetry/poetry

Issue:
ValueError: '=' alignment not allowed in string format specifier in show.py
<!--
  Hi there! Thank you for discovering and submitting an issue.

  Before you submit this; let's make sure of a few things.
  Please make sure the following boxes are ticked if they are correct.
  If not, please try and fulfill these first.
-->

<!-- Checked checkbox should look like this: [x] -->
- [x] I am on the [latest](https://github.com/sdispater/poetry/releases/latest) Poetry version.
- [x] I have searched the [issues](https://github.com/sdispater/poetry/issues) of this repo and believe that this is not a duplicate.
- [x] If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option).

<!--
  Once those are done, if you're able to fill in the following list with your information,
  it'd be very helpful to whoever handles the issue.
-->

- **OS version and name**: Raspbian GNU/Linux 10 (buster)
- **Poetry version**: 1.0.0b1
- **Link of a [Gist](https://gist.github.com/) with the contents of your pyproject.toml file**: https://gist.github.com/oakkitten/d003258493a887fde9906c6faaac946e

## Issue

Edit: just noted that I'm running a more late version than “the latest”, not sure what to do 🙄

Run

    $ poetry new woo
    $ cd woo
    (edit pyproject.toml to remove the test dependency and add `pendulum = "*"`, see gist)
    $ poetry install
    $ poetry show -o -vvv

Get

    Using virtualenv: /home/oakkitten/.cache/pypoetry/virtualenvs/woo-2dsX_qwR-py3.7

    [ValueError]
    '=' alignment not allowed in string format specifier

    Traceback (most recent call last):
      File "/home/oakkitten/.poetry/lib/poetry/_vendor/py3.7/clikit/console_application.py", line 132, in run
        status_code = command.handle(parsed_args, io)
      File "/home/oakkitten/.poetry/lib/poetry/_vendor/py3.7/clikit/api/command/command.py", line 119, in handle
        status_code = self._do_handle(args, io)
      File "/home/oakkitten/.poetry/lib/poetry/_vendor/py3.7/clikit/api/command/command.py", line 167, in _do_handle
        return getattr(handler, handler_method)(args, io, self)
      File "/home/oakkitten/.poetry/lib/poetry/_vendor/py3.7/cleo/commands/command.py", line 92, in wrap_handle
        return self.handle()
      File "/home/oakkitten/.poetry/lib/poetry/console/commands/show.py", line 177, in handle
        color, name, name_length - len(install_marker), install_marker

The variables in this last line are respectively `'cyan', 'pendulum', 0, ''`.

Not sure why the line numbers are different but it's [this code](https://github.com/sdispater/poetry/blob/master/poetry/console/commands/show.py#L153-L155), the issue being that `name_length - len(install_marker)` computes to `0` and python fails to interpret it as width (see [this issue](https://bugs.python.org/issue27772)).

Note that there are more of `{:{}}` in the code.


Discussion:
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Still an issue.
As noted in https://github.com/sdispater/poetry/issues/1605, this is still an issue.
Happens to me as well, providing more details.

- **OS version and name:** `python:3.7.5-slim-buster` Docker image
- **Poetry version:** 1.0.0b5
- **Link of a Gist with the contents of your pyproject.toml file:** https://gist.github.com/playpauseandstop/4efcf7d77db1df616dcea3e065e51935

The traceback is similar to what shared in issue description.

Resolving patch:
diff --git a/poetry/console/commands/show.py b/poetry/console/commands/show.py
--- a/poetry/console/commands/show.py
+++ b/poetry/console/commands/show.py
@@ -172,6 +172,13 @@ def handle(self):
                         # Non installed in non decorated mode
                         install_marker = " (!)"
 
+            if (
+                show_latest
+                and self.option("outdated")
+                and latest_statuses[locked.pretty_name] == "up-to-date"
+            ):
+                continue
+
             line = "<fg={}>{:{}}{}</>".format(
                 color, name, name_length - len(install_marker), install_marker
             )
@@ -183,9 +190,6 @@ def handle(self):
                 latest = latest_packages[locked.pretty_name]
                 update_status = latest_statuses[locked.pretty_name]
 
-                if self.option("outdated") and update_status == "up-to-date":
-                    continue
-
                 if write_latest:
                     color = "green"
                     if update_status == "semver-safe-update":


Test patch:
diff --git a/tests/console/commands/test_show.py b/tests/console/commands/test_show.py
--- a/tests/console/commands/test_show.py
+++ b/tests/console/commands/test_show.py
@@ -379,6 +379,46 @@ def test_show_outdated(app, poetry, installed, repo):
     assert expected == tester.io.fetch_output()
 
 
+def test_show_outdated_with_only_up_to_date_packages(app, poetry, installed, repo):
+    command = app.find("show")
+    tester = CommandTester(command)
+
+    cachy_020 = get_package("cachy", "0.2.0")
+    cachy_020.description = "Cachy package"
+
+    installed.add_package(cachy_020)
+    repo.add_package(cachy_020)
+
+    poetry.locker.mock_lock_data(
+        {
+            "package": [
+                {
+                    "name": "cachy",
+                    "version": "0.2.0",
+                    "description": "Cachy package",
+                    "category": "main",
+                    "optional": False,
+                    "platform": "*",
+                    "python-versions": "*",
+                    "checksum": [],
+                },
+            ],
+            "metadata": {
+                "python-versions": "*",
+                "platform": "*",
+                "content-hash": "123456789",
+                "hashes": {"cachy": []},
+            },
+        }
+    )
+
+    tester.execute("--outdated")
+
+    expected = ""
+
+    assert expected == tester.io.fetch_output()
+
+
 def test_show_outdated_has_prerelease_but_not_allowed(app, poetry, installed, repo):
     command = app.find("show")
     tester = CommandTester(command)