Poetry: Missing `license` key explodes rather than logging a useful message

Created on 17 Oct 2018  路  6Comments  路  Source: python-poetry/poetry

  • [x] I am on the latest Poetry version.
  • [x] I have searched the 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).
  • OS version and name: macOS 10.14
  • Poetry version: 0.12.0

Issue

After updating to 0.12.0, almost all commands fail because my pyproject.toml doesn't have a license field.

Verbose output:

> poetry shell -vvv

[AttributeError]               
'NoneType' object has no attribute 'lower'  

Exception trace:
 /Users/seankelley/.poetry/lib/poetry/_vendor/py3.6/cleo/application.py in run() at line 94
   status_code = self.do_run(input_, output_)
 /Users/seankelley/.poetry/lib/poetry/console/application.py in do_run() at line 88
   return super(Application, self).do_run(i, o)
 /Users/seankelley/.poetry/lib/poetry/_vendor/py3.6/cleo/application.py in do_run() at line 197
   status_code = command.run(input_, output_)
 /Users/seankelley/.poetry/lib/poetry/console/commands/command.py in run() at line 77
   return super(BaseCommand, self).run(i, o)
 /Users/seankelley/.poetry/lib/poetry/_vendor/py3.6/cleo/commands/base_command.py in run() at line 136
   self.initialize(input_, output_)
 /Users/seankelley/.poetry/lib/poetry/console/commands/env_command.py in initialize() at line 16
   o, self.poetry.package.name, cwd=self.poetry.file.parent
 /Users/seankelley/.poetry/lib/poetry/console/commands/command.py in poetry() at line 62
   return self.get_application().poetry
 /Users/seankelley/.poetry/lib/poetry/console/application.py in poetry() at line 60
   self._poetry = Poetry.create(os.getcwd())
 /Users/seankelley/.poetry/lib/poetry/poetry.py in create() at line 120
   license_ = license_by_id(local_config.get("license"))
 /Users/seankelley/.poetry/lib/poetry/spdx/__init__.py in license_by_id() at line 14
   id = identifier.lower()

shell

I would expect it to fail in the same way that it does for other missing keys:

[NonExistentKey]  
'Key "name" does not exist.'   

...or to not require a license field at all (why does it?).

Most helpful comment

Sorry about that!

I just published a new release with this bug fixed.

All 6 comments

Seeing how poetry init does not force you to choose a License and how it would break old projects I don't think it should be required to specify one.

Here's a temporary workaround:

# pyproject.toml

[tool.poetry]
...
license = ""

Sorry about that!

I just published a new release with this bug fixed.

Thanks for the quick fix, looks like it works!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nikaro picture nikaro  路  3Comments

AWegnerGitHub picture AWegnerGitHub  路  3Comments

probablykasper picture probablykasper  路  3Comments

mozartilize picture mozartilize  路  3Comments

ghost picture ghost  路  3Comments