Skip to content

Add "authors" as a required field in config schema#2540

Closed
rpdelaney wants to merge 1 commit into
python-poetry:masterfrom
rpdelaney:required_properties
Closed

Add "authors" as a required field in config schema#2540
rpdelaney wants to merge 1 commit into
python-poetry:masterfrom
rpdelaney:required_properties

Conversation

@rpdelaney
Copy link
Copy Markdown
Contributor

Before this change, a pyproject.toml file without an "authors" field would throw an unhandled NonExistentKey exception. Now it will be returned as a config validation error, as with the "name", "version", and "description" fields.

Before
$ poetry install -vvv
[NonExistentKey]
'Key "authors" does not exist.'

Traceback (most recent call last):
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/clikit/api/command/command.py", line 163, in _do_handle
    self._dispatcher.dispatch(PRE_HANDLE, event)
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/clikit/api/event/event_dispatcher.py", line 22, in dispatch
    self._do_dispatch(listeners, event_name, event)
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/clikit/api/event/event_dispatcher.py", line 89, in _do_dispatch
    listener(event, event_name, self)
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/console/config/application_config.py", line 86, in set_env
    poetry = command.poetry
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/console/commands/command.py", line 10, in poetry
    return self.application.poetry
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/console/application.py", line 49, in poetry
    self._poetry = Factory().create_poetry(Path.cwd())
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/factory.py", line 62, in create_poetry
    for author in local_config["authors"]:
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/tomlkit/items.py", line 1008, in __getitem__
    return self._value[key]
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/tomlkit/container.py", line 540, in __getitem__
    raise NonExistentKey(key)
After
$ poetry install -vvv
[RuntimeError]
The Poetry configuration is invalid:
  - 'authors' is a required property


Traceback (most recent call last):
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/clikit/api/command/command.py", line 163, in _do_handle
    self._dispatcher.dispatch(PRE_HANDLE, event)
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/clikit/api/event/event_dispatcher.py", line 22, in dispatch
    self._do_dispatch(listeners, event_name, event)
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/clikit/api/event/event_dispatcher.py", line 89, in _do_dispatch
    listener(event, event_name, self)
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/console/config/application_config.py", line 86, in set_env
    poetry = command.poetry
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/console/commands/command.py", line 10, in poetry
    return self.application.poetry
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/console/application.py", line 49, in poetry
    self._poetry = Factory().create_poetry(Path.cwd())
  File "/Users/ryan/.local/pipx/venvs/poetry/lib/python3.7/site-packages/poetry/factory.py", line 54, in create_poetry
    raise RuntimeError('The Poetry configuration is invalid:
'" + message)

Pull Request Check List

  • Added tests for changed code.

I didn't do this, because:

  1. I couldn't find a way to add a test without breaking many other tests in a reasonable time.
    • My first try was on test_factory.py line 184, but adding a line with - 'authors' is a required property broke a whole lot of other tests.
  2. The tests don't seem to check for all the other required fields besides "description" as they are.

I'd be happy to add a test but I will need either more time or a bit of guidance.

  • Updated documentation for changed code.

I don't believe this is applicable.

Before this change, a pyproject.toml file without an "authors" field
would throw an unhandled `NonExistentKey` exception. Now it will be
returned as a config validation error, as with the "name", "version",
and "description" fields.
@finswimmer finswimmer requested a review from a team June 11, 2020 10:10
@abn
Copy link
Copy Markdown
Member

abn commented Jun 11, 2020

@rpdelaney can you rereate this for poetry-core instead please?

@rpdelaney
Copy link
Copy Markdown
Contributor Author

@abn Done here

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 1, 2024

This pull request 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants