google / google/python-fire

How to parse list of integers

Aberta
#624 1 comentário 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Python
Estrelas
28.2k
Forks
1.5k
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

With argparse, you can do:
```
> python example.py --this 123
> python example.py --this 123 456
> python example.py --this 123 456 789
```
With Fire, how do you parse a list of integers (including a single element list) like argparse?

```
# example.py
import fire

def main(this: list[int]):
print(type(this), this)

if __name__ == '__main__':
fire.Fire(main)
```
```
> python example.py --this 123
123

> python example.py --this 123 456
ERROR: Could not consume arg: 456

> python example.py --this 123 456 789
ERROR: Could not consume arg: 456
```

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

Start by running the example.py commands from the issue and trace how Python Fire consumes arguments for the annotated main(this: list[int]) entry point. Check the existing argument-parsing tests and compare the single-value and multi-value cases. Done means one or more integer values are accepted for --this and exposed to main as a list.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
cli
Tipo de issue
Funcionalidade
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Pouca atividade
Clareza
Razoavelmente clara
Facilidade para iniciantes
55/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.