Skip to content

feat: allow multiple --author flags in poetry init#10746

Open
ddarji1409 wants to merge 1 commit intopython-poetry:mainfrom
ddarji1409:fix/multiple-authors-flag
Open

feat: allow multiple --author flags in poetry init#10746
ddarji1409 wants to merge 1 commit intopython-poetry:mainfrom
ddarji1409:fix/multiple-authors-flag

Conversation

@ddarji1409
Copy link

@ddarji1409 ddarji1409 commented Feb 23, 2026

Summary

Closes #8864.

poetry init --author previously accepted only a single value. This change allows the flag to be passed multiple times:

poetry init --author "Alice <alice@example.com>" --author "Bob <bob@example.com>"

Changes

src/poetry/console/commands/init.py

  • Added multiple=True to the --author option definition (consistent with how --dependency and --dev-dependency are declared)
  • Updated author processing logic: if any --author flags are provided, they're used directly as the authors list, skipping the interactive prompt
  • Existing behavior preserved: when no --author flags are given, falls back to git config and interactive prompt as before

Test plan

  • test_validate_author — passes
  • test_noninteractive — passes (exercises --author flag, now correctly handles tuple)
  • Single --author flag still works (backwards compatible)
  • Multiple --author flags now accepted

🤖 Generated with Claude Code

Summary by Sourcery

New Features:

  • Support multiple --author flags for poetry init to define an explicit list of authors non-interactively.

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>
@sourcery-ai
Copy link

sourcery-ai bot commented Feb 23, 2026

Reviewer's Guide

Adds support for specifying multiple --author flags in poetry init and adjusts author collection logic to prefer CLI-provided authors while preserving existing interactive and VCS-based behavior when no authors are passed.

Flow diagram for updated author resolution in poetry init

flowchart 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
Loading

File-Level Changes

Change Details Files
Allow multiple --author flags and treat them as the authoritative authors list when provided.
  • Updated the InitCommand options to declare the author option with multiple=True, aligning it with dependency options that accept multiple values.
  • Changed author resolution to first collect all --author flag values into a list and, when present, use them directly as the authors list without prompting interactively.
  • Retained the previous flow for deriving a default author from VCS config and prompting the user only when no --author flags are given, then wrapping the final author (if any) into an authors list.
src/poetry/console/commands/init.py

Assessment against linked issues

Issue Objective Addressed Explanation
#8864 Enable specifying multiple authors for poetry init non-interactively (e.g., via CLI options such as --author).
#8864 Update documentation to describe how to specify multiple authors when running poetry init. The PR only changes the command implementation in init.py and does not include any documentation updates explaining the new multiple --author usage.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

poetry init --author doesn't seem to allow multiple authors on Windows

1 participant