question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default is ignored on lists

See original GitHub issue

It seems that the default-key is ignored on list-type questions

Consider the following code:

from PyInquirer import prompt, print_json

answer = prompt({
        'type': 'list',
        'name': "test-question",
        'message': "Select item",
        'default': 2,
        'choices': [
            {   "name"  : "Item 1",
                "value" : "item1"   },
            {   "name"  : "Item 2",
                "value" : "item2"   },
            {   "name"  : "Item 3",
                "value" : "item3"   },
            {   "name"  : "Item 4",
                "value" : "item4"   },
        ]
    })

print_json(answer)

Expected result:

Item 3 is initially selected in the prompt

Actual result:

Item 1 is initially selected in the prompt

Environment:

OS: macOS 10.14 Mojave

$ python3 --version
Python 3.6.1
$ python3 -m pip show PyInquirer
Name: PyInquirer
Version: 1.0.2
Summary: A Python module for collection of common interactive command line user interfaces, based on Inquirer.js
Home-page: https://github.com/CITGuru/PyInquirer/
Author: Oyetoke Toby
Author-email: oyetoketoby80@gmail.com
License: MIT
Location: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Requires: prompt-toolkit, Pygments, regex
Required-by:

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
ajdaviscommented, Feb 22, 2020

I believe this issue should be reopened, it’s still present in version 1.0.3 on PyPI and on master.

6reactions
martenjacobscommented, Nov 12, 2018

From documentation it appears you should be able to define the initially selected list item. Either the documentation should be clarified or this feature should be implemented.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Where is the SVN default list of ignored files? - Stack Overflow
You can find the default global file ignore list in the auto-generated user specific config file, in a commented-out line (key global-ignores in...
Read more >
Types And Syntax Of Ignore Lists (Stow) - GNU.org
If neither the package-local or global ignore list exist, Stow will use its own built-in default ignore list, which serves as a useful...
Read more >
Editing the Default Value for Ignored Fields During List Import
Hi, When I import a list from a csv. file, in the preview Marketo automatically assigns any empty columns to 'Phone Number' as...
Read more >
ignoring an empty list when using with_flattened
If the list is undefined, I get an error, and if I use something like host_users_ro|default(omit), I get an error on 'name' not...
Read more >
List of file types that are ignored by default | Insync Help Center
There are some file types that are ignored by default even if it's not in your Ignore Rules. Read more about that here....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found