Skip to content

poetry plugin show crash with obscure error message #4345

@Conchylicultor

Description

@Conchylicultor
  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: MacOs

  • Poetry version: 1.2.0a2

  • Link of a Gist with the contents of your pyproject.toml file:

[tool.poetry]
name = "nightly_release"
version = "0.1.0"
description = "Poetry plugin to setup automated release"
authors = ["Sunds team <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.7"

[tool.poetry.dev-dependencies]
pytest = "*"

[tool.poetry.plugins."poetry.plugin"]
demo = "nightly_release:NightlyReleasePlugin"

[build-system]
requires = ["poetry-core>=1.1.0a6"]
build-backend = "poetry.core.masonry.api"

Issue

I'm trying to develop a poetry plugin locally. I'm trying a dummy plugin:

import cleo.io.io
import poetry.plugins
import poetry.poetry


class NightlyReleasePlugin(poetry.plugins.Plugin):

    def activate(self, poetry: poetry.poetry.Poetry, io: cleo.io.io.IO):
        io.write_line(repr(poetry))
        print(poetry)

As there is no good way to install package globally in development mode (like pip install -e), I'm forced to recompile the package every time (which is not a good developer experience):

pip uninstall -y nightly-release
poetry build
pip install .

After the plugin is installed, I'm trying to check if the plugin is correctly detected with poetry plugin show, but got the following error:

$ poetry plugin show

  KeyError

  'demo'

  at /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/console/commands/plugin/show.py:54 in handle
       50category = "plugins"
       51if issubclass(plugin, ApplicationPlugin):
       52category = "application_plugins"
       53│ 
    →  54package = packages_by_name[canonicalize_name(entry_point.name)]
       55plugins[package.pretty_name]["package"] = package
       56plugins[package.pretty_name][category].append(entry_point)
       5758for name, info in plugins.items():
Full stacktrace. Click to expand!
epot-macbookpro2:~ epot$ poetry plugin show -vvv

  Stack trace:

  7  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cleo/application.py:330 in run
      328329try:
    → 330exit_code = self._run(io)
      331except Exception as e:
      332if not self._catch_exceptions:

  6  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/console/application.py:180 in _run
      178self._load_plugins(io)
      179│ 
    → 180return super()._run(io)
      181182def _configure_io(self, io: IO) -> None:

  5  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cleo/application.py:425 in _run
      423io.set_input(ArgvInput(argv))
      424│ 
    → 425exit_code = self._run_command(command, io)
      426self._running_command = None
      4274  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cleo/application.py:467 in _run_command
      465466if error is not None:
    → 467raise error
      468469return event.exit_code

  3  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cleo/application.py:451 in _run_command
      449450if event.command_should_run():
    → 451exit_code = command.run(io)
      452else:
      453exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

  2  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cleo/commands/base_command.py:118 in run
      116io.input.validate()
      117│ 
    → 118status_code = self.execute(io)
      119120if status_code is None:

  1  /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cleo/commands/command.py:85 in execute
       8384try:
    →  85return self.handle()
       86except KeyboardInterrupt:
       87return 1

  KeyError

  'demo'

  at /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/console/commands/plugin/show.py:54 in handle
       50category = "plugins"
       51if issubclass(plugin, ApplicationPlugin):
       52category = "application_plugins"
       53│ 
    →  54package = packages_by_name[canonicalize_name(entry_point.name)]
       55plugins[package.pretty_name]["package"] = package
       56plugins[package.pretty_name][category].append(entry_point)
       5758for name, info in plugins.items():

I'm confident that the entry point is correct and my plugin is correctly loaded:

  • If I uninstall my plugin (pip uninstall -y nightly-release), the error goes away
  • If an error happens during the import process (e.g. make a typo poetry.poetry.PoetryWrong), poetry plugin show correctly crash with PoetryWrong undefined error.

I also get other error message when trying other commands:

$ poetry publish --dry-run

  AttributeError

  'IO' object has no attribute 'ask'

  at /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/publishing/publisher.py:82 in publish
       78│         )
       79# Requesting missing credentials but only if there is not a client cert defined.
       80if not resolved_client_cert:
       81if username is None:
    →  82username = self._io.ask("Username:")
       8384# skip password input if no username is provided, assume unauthenticated
       85if username and password is None:
       86password = self._io.ask_hidden("Password:")

My cleo version installed is cleo==1.0.0a4

What is this error about ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expectedstatus/triageThis issue needs to be triaged

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions