[bug] short flags/arguments does not work with `**kwargs`
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 45/100
Piste de recherche
Exécutez les deux exemples Python de l'issue et comparez le comportement des options courtes avec et sans kwargs. Suivez ensuite l'analyse des arguments de Python Fire pour les options courtes et les arguments nommés. Le travail est terminé lorsque -f et -s alimentent first_arg et second_arg, tandis que les flags sans rapport continuent d'apparaître dans kwargs, avec une couverture de régression pour les deux cas.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Description:
Short flags/arguments (e.g. -u for --username) does not work with **kwargs
Example that works OK:
The following example works ok:
import fire
def cli(first_arg="left", second_arg="right"):
"""Prints the 2 arguments separated by bar
Parameters
----------
first_arg : str
the first arg
second_arg : str
the second arg
"""
print(f"{first_arg} | {second_arg}" )
if __name__ == '__main__':
fire.Fire(cli)
Help output
❯ python .\example.py -- --help
NAME
example.py - Prints the 2 arguments separated by bar
SYNOPSIS
example.py <flags>
DESCRIPTION
Prints the 2 arguments separated by bar
FLAGS
-f, --first_arg=FIRST_ARG
Default: 'left'
the first arg
-s, --second_arg=SECOND_ARG
Default: 'right'
the second arg
Usage with short flags
❯ python .\example.py -f="hello" -s="word"
hello | word
Example that does not work:
The following next example does not work with short flags, even when they are showing on the help output.
It is using **kwargs. It seems the short flags are going to the **kwargs dictionary.
import fire
def cli(first_arg="left", second_arg="right", **kwargs):
"""Prints the 2 arguments separated by bar
Parameters
----------
first_arg : str
the first arg
second_arg : str
the second arg
kwargs : str
additional args
"""
print(f"{first_arg} | {second_arg}" )
print(kwargs)
if __name__ == '__main__':
fire.Fire(cli)
Help output
❯ python .\example2.py -- --help
NAME
example2.py - Prints the 2 arguments separated by bar
SYNOPSIS
example2.py <flags>
DESCRIPTION
Prints the 2 arguments separated by bar
FLAGS
-f, --first_arg=FIRST_ARG
Default: 'left'
the first arg
-s, --second_arg=SECOND_ARG
Default: 'right'
the second arg
Additional flags are accepted.
additional args
Usage with short flags
❯ python .\example2.py -f="hello" -s="word"
left | right
{'f': 'hello', 's': 'word'}
In summary: the -f and -s arguments should be parsing to --first_arg and --second_arg but they are parsing to kwargs
- Langage dominant
- Python
- Étoiles
- 28.2k
- Forks
- 1.5k
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de google/python-fire
-
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
google/python-fire#693 ·
-
Release 0.7.2?Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 38/100
google/python-fire#698 ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 58/100
google/python-fire#672 · 5 commentaires ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
google/python-fire#665 · 2 commentaires ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 55/100
google/python-fire#659 · 1 commentaire ·
Toutes les issues de google/python-fire
Issues similaires
-
good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
vllm-project/vllm-metal#822 ·
Les mainteneurs répondent en général sous 1 jour
-
vector-store
Difficulté 1/5 1-3 heures Accessibilité débutants 90/100
mem0ai/mem0#7461 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
[Bug]: chunk_span_bounds and _validated_chunk_spans reject Pydantic models ChunkSpan and AudioFileOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
BasedHardware/omi#19047 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
Les mainteneurs répondent en général sous 1 jour