python / python/cpython

custom prefixes for `argparse.BooleanOptionalAction`

Abierto
#119,377 2 comentarios 0 reacciones 1 asignado Ver en GitHub

@serhiy-storchaka ya está trabajando en esto.

Desde el 23/10/2024.

stdlib type-feature
Lenguaje dominante
Python
Estrellas
77.2k
Forks
36k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

Feature or enhancement

Proposal:

At the moment, argparse.BooleanOptionalAction gives e.g. --foo vs --no-foo, whose prefix is hardcoded:

https://github.com/python/cpython/blob/cd516cd1f5e94dba887353f421513fd172efadf3/Lib/argparse.py#L848
https://github.com/python/cpython/blob/cd516cd1f5e94dba887353f421513fd172efadf3/Lib/argparse.py#L863

It would be beneficial if we can change the prefixes of the binary options: e.g. --enable- vs --disable- like autoconf.

usage: [-h] [--enable-foo | --disable-foo]

options:
  -h, --help            show this help message and exit
  --enable-foo, --disable-foo
                        helpstring for foo
Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

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.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.