Skip to content

fix: update return types of dialog shortcuts to include None when cancelled#2078

Open
motty-mio2 wants to merge 1 commit into
prompt-toolkit:mainfrom
motty-mio2:feature/typecheck_on_dialog
Open

fix: update return types of dialog shortcuts to include None when cancelled#2078
motty-mio2 wants to merge 1 commit into
prompt-toolkit:mainfrom
motty-mio2:feature/typecheck_on_dialog

Conversation

@motty-mio2

Copy link
Copy Markdown
Contributor

Summary

The return types of input_dialog, radiolist_dialog, and checkboxlist_dialog shortcuts did not account for the case where the user cancels the dialog.
When cancelled, these dialogs return None, but their return types were typed as Application[str], Application[_T], and
Application[list[_T]] respectively.

This PR updates their return types to:

  • input_dialog: Application[str | None]
  • radiolist_dialog: Application[_T | None]
  • checkboxlist_dialog: Application[list[_T] | None]

This allows type checkers like mypy/pyright to correctly type-check code that handles dialog cancellation.

How to Test / Reproduction

Run your type checker (e.g., mypy) against the attached reproduction script dialog_tester.py. It should type-check successfully without errors.

dialog_tester.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant