InquirerPy icon indicating copy to clipboard operation
InquirerPy copied to clipboard

Incorrect type hint for `execute_async` as `None`, when it should be `Any`

Open ionite34 opened this issue 3 years ago • 0 comments

https://github.com/kazhala/InquirerPy/blob/master/InquirerPy/base/simple.py#L341-L355

The execute_async function has been incorrectly hinted to return None, when all the return paths actually return Any, as returned by await self._run_async()

    async def execute_async(self) -> None:
        """Run the prompt asynchronously and get the result.
        Returns:
            Value of the user answer. Types varies depending on the prompt.
        Raises:
            KeyboardInterrupt: When `ctrl-c` is pressed and `raise_keyboard_interrupt` is True.
        """
        result = await self._run_async()
        if result == INQUIRERPY_KEYBOARD_INTERRUPT:
            raise KeyboardInterrupt
        if not self._filter:
            return result
        return self._filter(result)

This currently causes problems in downstream IDEs and type checked libraries as the result of this couroutine is improperly expected to be None instead of the return value:

img

ionite34 avatar Aug 20 '22 21:08 ionite34