feat: allow multiple --author flags in poetry init#10746
Open
ddarji1409 wants to merge 1 commit intopython-poetry:mainfrom
Open
feat: allow multiple --author flags in poetry init#10746ddarji1409 wants to merge 1 commit intopython-poetry:mainfrom
ddarji1409 wants to merge 1 commit intopython-poetry:mainfrom
Conversation
Change the --author option to accept multiple=True so users can pass multiple --author flags (e.g. --author "Alice <a@x.com>" --author "Bob <b@x.com>"). Update the author processing logic in _init_pyproject to build the authors list directly from all provided --author values, falling back to the existing interactive/vcs-config behaviour when no flag is given. Fixes python-poetry#8864 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reviewer's GuideAdds support for specifying multiple --author flags in Flow diagram for updated author resolution in poetry initflowchart TD
Start["Start _init_pyproject"] --> GetOption["Get author options as list: authors_from_option = list(option(author))"]
GetOption --> HasCLIAuthors{Any CLI authors?}
HasCLIAuthors -- Yes --> UseCLIAuthors["Set authors = authors_from_option"]
UseCLIAuthors --> End["Continue with pyproject initialization"]
HasCLIAuthors -- No --> InitAuthorVar["Set author = None"]
InitAuthorVar --> HasVCSName{vcs_config has user.name?}
HasVCSName -- Yes --> BuildAuthorName["Set author = vcs_config[user.name]"]
BuildAuthorName --> HasVCSEmail{vcs_config has user.email?}
HasVCSEmail -- Yes --> AppendEmail["Append <user.email> to author"]
HasVCSEmail -- No --> SkipEmail["Keep author without email"]
AppendEmail --> CheckInteractive
SkipEmail --> CheckInteractive
HasVCSName -- No --> CheckInteractive
CheckInteractive{is_interactive?} -- Yes --> AskQuestion["Ask interactive author question with default = author"]
AskQuestion --> ValidateAuthor["Validate answer with _validate_author"]
ValidateAuthor --> SetAuthorFromAnswer["Set author to validated answer"]
SetAuthorFromAnswer --> BuildAuthorsList
CheckInteractive -- No --> BuildAuthorsList
BuildAuthorsList["Set authors = [author] if author else []"] --> End
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Summary
Closes #8864.
poetry init --authorpreviously accepted only a single value. This change allows the flag to be passed multiple times:Changes
src/poetry/console/commands/init.pymultiple=Trueto the--authoroption definition (consistent with how--dependencyand--dev-dependencyare declared)--authorflags are provided, they're used directly as the authors list, skipping the interactive prompt--authorflags are given, falls back to git config and interactive prompt as beforeTest plan
test_validate_author— passestest_noninteractive— passes (exercises--authorflag, now correctly handles tuple)--authorflag still works (backwards compatible)--authorflags now accepted🤖 Generated with Claude Code
Summary by Sourcery
New Features:
poetry initto define an explicit list of authors non-interactively.