CITGuru / PyInquirer

A Python module for common interactive command line user interfaces
MIT License
1.91k stars 235 forks source link

[bug] 'default' property doesn't accept numbers #155

Open tiamilani opened 3 years ago

tiamilani commented 3 years ago

Hello, I didn't find a previous issue for the same problem. When I try to use as default a number, for example, 1234, in an input question I get an error. While, if I use a string, "1234" I don't get the error. Maybe it's only inconsistency with the documentation (default: (String|Number|Array|Function)).

I don't think it's relevant but I'm using a virtual environment.

Code to reproduce the error:

>>> from PyInquirer import prompt
>>> question = [{'type': 'input', 'name': 'test', 'message': 'insert number', 'default': "1234"}]
>>> prompt(question)
? insert number  123
{'test': '123'}
>>> question = [{'type': 'input', 'name': 'test', 'message': 'insert number', 'default': 1234}]
>>> prompt(question)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "env/lib/python3.6/site-packages/PyInquirer/prompt.py", line 67, in prompt
    application = getattr(prompts, type).question(message, **_kwargs)
  File "env/lib/python3.6/site-packages/PyInquirer/prompts/input.py", line 50, in question
    **kwargs
  File "env/lib/python3.6/site-packages/prompt_toolkit/shortcuts.py", line 500, in create_prompt_application
    initial_document=Document(default),
  File "env/lib/python3.6/site-packages/prompt_toolkit/document.py", line 83, in __init__
    assert isinstance(text, six.text_type), 'Got %r' % text
AssertionError: Got 1234

If you need other details just ask, I will be more than glad to provide them