argparse exclusive argument group error unintelligible

Abierto
#157,127 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
30/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
python
Área
cli

Línea de trabajo

Comienza con el punto de entrada de argparse para mutually exclusive-group mostrado en el informe y reproduce el comando sin --stdout ni repository. Rastrea el diagnóstico resultante del argumento obligatorio y su cobertura existente; se considera terminado cuando el mensaje visible para el usuario sea gramatical y explique claramente el requisito, con una prueba de regresión para este caso.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

stdlib type-bug

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
Lenguaje dominante
Python
Estrellas
77.2k
Forks
36k
Merge medio
1 d 9 h
PR fusionados (30 d)
558

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de python/cpython

Todos los issues de python/cpython

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.