Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip get_hint if no hints are defined #526

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/inquirer/questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(
self._validate = validate
self.answers = {}
self.show_default = show_default
self.hints = hints or {}
self.hints = hints
self._other = other

if self._other:
Expand Down
4 changes: 3 additions & 1 deletion src/inquirer/render/console/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def _print_header(self, render):

def _print_hint(self, render):
msg_template = "{t.move_up}{t.clear_eol}{color}{msg}"
hint = render.get_hint()
hint = ""
if render.question.hints is not None:
hint = render.get_hint()
color = self._theme.Question.mark_color
if hint:
self.print_str(
Expand Down
16 changes: 16 additions & 0 deletions tests/integration/console_render/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,19 @@ def test_second_hint_is_shown(self):
sut.render(question)

self.assertInStdout("Bar")

def test_taggedValue_with_dict(self):
stdin = helper.event_factory(key.DOWN, key.ENTER)
message = "Foo message"
variable = "Bar variable"
choices = [
("aa", {"a": 1}),
("bb", {"b": 2}),
]

question = questions.List(variable, message, choices=choices)

sut = ConsoleRender(event_generator=stdin)
sut.render(question)

self.assertInStdout("bb")
Loading