argparse exclusive argument group error unintelligible
Đang mở
Chưa có ai nhận issue này.
stdlib
type-bug
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với điểm vào argparse của mutually exclusive-group được nêu trong báo cáo và tái hiện lệnh mà không có --stdout hoặc repository. Truy vết chẩn đoán tương ứng với đối số bắt buộc và phần bao phủ hiện có; được xem là hoàn tất khi thông báo hướng đến người dùng đúng ngữ pháp và giải thích rõ yêu cầu, kèm theo một bài kiểm thử hồi quy cho trường hợp này.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- cli
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 30/100