google / google/python-fire

Optional type args are mistyped in help

Abierto
#508 5 comentarios 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
Python
Estrellas
28.2k
Forks
1.5k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Type annotations that use `typing.Optional` are incorrectly documented when showing help.

## Example 1

```python
from typing import Optional

import fire

def main(arg: Optional[str] = 'something'):
"""Do something with arg."""

if __name__ == '__main__':
fire.Fire(main)
```

The corresponding help output is:

```
INFO: Showing help with the command 'firetest.py -- --help'.

NAME
firetest.py - Do something with arg.

SYNOPSIS
firetest.py

DESCRIPTION
Do something with arg.

FLAGS
-a, --arg=ARG
Type: Optional
Default: 'something'
```

**Here, `Type: Optional` is totally incorrect. It should be `Optional[str]`.** My use of `str` is just an example and it can be anything.

## Example 2

```python
from typing import Optional

import fire

def main(arg: Optional[str] = None):
"""Do something with arg."""

if __name__ == '__main__':
fire.Fire(main)
```

The corresponding help output is:

```
INFO: Showing help with the command 'firetest.py -- --help'.

NAME
firetest.py - Do something with arg.

SYNOPSIS
firetest.py

DESCRIPTION
Do something with arg.

FLAGS
-a, --arg=ARG
Type: Optional[Optional]
Default: None
```

**Here, `Type: Optional[Optional]` is even more incorrect. It should be `Optional[str]`.** My use of `str` is just an example and it can be anything.

Guía de contribución

Abrir la guía de contribución

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.