[bug] short flags/arguments does not work with `**kwargs`
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 45/100
Direção de pesquisa
Execute os dois exemplos Python da issue e compare o comportamento das opções curtas com e sem kwargs. Em seguida, rastreie o parsing de argumentos do Python Fire para opções curtas e argumentos nomeados. A tarefa estará concluída quando -f e -s preencherem first_arg e second_arg, enquanto flags não relacionadas continuarem aparecendo em kwargs, com cobertura de regressão para ambos os casos.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
- Linguagem predominante
- Python
- Estrelas
- 28.2k
- Forks
- 1.5k
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de google/python-fire
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
google/python-fire#705 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
google/python-fire#703 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
google/python-fire#693 ·
-
Release 0.7.2?Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 38/100
google/python-fire#698 ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 58/100
google/python-fire#672 · 5 comentários ·
Todas as issues de google/python-fire
Issues semelhantes
-
upstream update
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
conan-io/conan-center-index#31098 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
john-kurkowski/tldextract#382 ·
-
comp/tools duplicate P2 sweeper:risk-compatibility tool/mcp type/bug
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
NousResearch/hermes-agent#132042 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
deepset-ai/haystack#13092 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 85/100
feder-cr/invisible_playwright_mcp#1408 ·
Mantenedores costumam responder em até 1 dia