Allow multiple authors in poetry init and poetry new - #11091
Closed
fahadhewad wants to merge 2 commits into
Closed
fahadhewad wants to merge 2 commits into
fahadhewad wants to merge 2 commits into
Conversation
The --author option was declared as a single value option, so passing it twice kept only the last value, and passing a comma separated list wrote a malformed email address into pyproject.toml. Neither case reported an error. Declare --author as a multiple option, the same way --dependency and --dev-dependency are declared, and let Layout take a list of authors instead of one. poetry new reuses the option from InitCommand, so it accepts several authors too. In interactive mode only the first author is prompted for, and any further author given on the command line is kept.
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/poetry/console/commands/init.py" line_range="173" />
<code_context>
author = self.ask(question)
-
- authors = [author] if author else []
+ authors = [author, *authors[1:]] if author else []
license_name = self.option("license")
</code_context>
<issue_to_address>
**issue (bug_risk):** When an interactive user answers `n` to skip the first author, `authors` is set to an empty list, so every additional author supplied on the command line is discarded instead of being retained.
**Triggers:** When `poetry init` or `poetry new` runs interactively with multiple `--author` options and the user skips the prompted first author.
**Suggested fix:** Preserve the remaining authors in the false branch, for example by assigning `authors = authors[1:]` when `author` is empty.
```suggestion
authors = [author, *authors[1:]] if author else authors[1:]
```
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and if the author handling is wrong, poetry init or poetry new could write incorrect author metadata into a generated pyproject.toml. Reverting the change would not alter projects already generated, but the metadata is bounded and can be corrected or regenerated.
Blocking findings: src/poetry/console/commands/init.py:173
Contributor
Answering n to the interactive author prompt set the author list to empty, so any further author passed with --author on the command line was dropped. Only the prompted first author should be skipped. Drop just the first entry instead, and add a regression test covering an interactive run that skips the prompted author while a second one is given on the command line.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Check List
Resolves: #8864
Fixes #8864.
The
--authoroption ofpoetry initwas declared as a single value option, so passing it twice kept only the last value, and passing a comma separated list wrote a malformed email address intopyproject.toml. Neither case reported an error.Before this change the command above wrote
and it now writes
--authoris now declared as a multiple option, the same way--dependencyand--dev-dependencyalready are, andLayouttakes a list of authors instead of a single one.poetry newreuses the option fromInitCommand, so it accepts several authors as well. In interactive mode only the first author is prompted for, and any further author given on the command line is kept, so runs with a single author behave as before.