Skip to content

Commit

Permalink
fix(types): declare support for single questions
Browse files Browse the repository at this point in the history
Without this patch, when calling `prompt` or `unsafe_prompt` with a `dict` on `questions`, mypy fails with:

    Argument 1 to "unsafe_prompt" has incompatible type "Dict[str, Any]"; expected "Iterable[Mapping[str, Any]]"
  • Loading branch information
yajo committed Dec 19, 2021
1 parent d13e7e5 commit 83391fa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions questionary/prompt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from prompt_toolkit.output import ColorDepth
from typing import Any, Dict, Optional, Iterable, Mapping
from typing import Any, Dict, Optional, Iterable, Mapping, Union

from questionary import utils
from questionary.constants import DEFAULT_KBI_MESSAGE
Expand All @@ -13,7 +13,7 @@ def __init__(self, message: str, errors: Optional[BaseException] = None) -> None


def prompt(
questions: Iterable[Mapping[str, Any]],
questions: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]],,
answers: Optional[Mapping[str, Any]] = None,
patch_stdout: bool = False,
true_color: bool = False,
Expand Down Expand Up @@ -74,7 +74,7 @@ def prompt(


def unsafe_prompt(
questions: Iterable[Mapping[str, Any]],
questions: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]],,
answers: Optional[Mapping[str, Any]] = None,
patch_stdout: bool = False,
true_color: bool = False,
Expand Down

0 comments on commit 83391fa

Please sign in to comment.