python / python/cpython

argparse exclusive argument group error unintelligible

未關閉
#157,127 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

stdlib type-bug
主要語言
Python
星號
77.2k
分支
36k
PR 合併指標
PR 指標待擷取

描述

Bug report

Bug description:
    import argparse
    import os.path
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--debug",
        action="store_true",
        help="print out debugging information",
    )
    # Added optional branch argument
    parser.add_argument(
        "-b",
        "--branch",
        default="main",
        help="branch name to store commits in (default: main)",
    )
    parser.add_argument(
        "--non-interactive",
        action="store_true",
        help="disable interactive prompts for missing author information, pass --yes to lfs import",
    )
    parser.add_argument(
        "--template",
        default=os.path.join(
            os.path.dirname(__file__), "template"
        ),
        help="add files from this directory to every revision",
    )
    parser.add_argument(
        "--object-format",
        default="sha256",
        help="git object format to use (default: sha256)",
    )
    parser.add_argument(
        "--changelog",
        nargs="?",
        const=pkg_base,
        help="use changelog for commit messages, "
        f"package name is guessed ({pkg_base}) or can be specified",
    )
    repo_group = parser.add_mutually_exclusive_group(required=True)
    repo_group.add_argument(
        "--stdout",
        action="store_true",
        help="output git fast-import data to stdout",
    )
    repo_group.add_argument(
        "repository",
        nargs="?",
        help="import package into this git repository if --stdout is not given",
    )
    args = parser.parse_args()

$ python3 osc_fast_export.py 
usage: osc_fast_export.py [-h] [--debug] [-b BRANCH] [--non-interactive] [--template TEMPLATE]
                          [--object-format OBJECT_FORMAT] [--changelog [CHANGELOG]] (--stdout |
                          repository)
osc_fast_export.py: error: one of the arguments --stdout repository is required

The sentence

one of the arguments --stdout repository is required

is unintelligible. I wrote the code so I know why the output is like this but this is supposed to be read by a user who never looked at the code. The grammar of that sentence is broken.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs
  • gh-157134

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從報告中展示的 argparse mutually exclusive-group 入口點開始,在既不使用 --stdout 也不使用 repository 的情況下重現該命令。追蹤由此產生的必要引數診斷及其現有涵蓋;完成的標準是,面向使用者的訊息文法正確、清楚地說明這項要求,並為此情況提供回歸測試。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
cli
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
描述清楚
新手友好度
30/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。