Skip to content

Expose validate_while_typing on text-based prompts - #526

Closed
Nagaraaa wants to merge 1 commit into
tmbo:masterfrom
Nagaraaa:expose-validation-timing
Closed

Nagaraaa wants to merge 1 commit into
tmbo:masterfrom
Nagaraaa:expose-validation-timing

Conversation

@Nagaraaa

@Nagaraaa Nagaraaa commented Oct 20, 2026 •

Copy link
Copy Markdown

What is the problem that this PR addresses?

Related to #514. Expensive validators can delay typing. validate_while_typing=False already works through **kwargs, but the option is absent from Questionary's public signatures and parameter documentation.

How did you solve it?

Expose validate_while_typing as a keyword-only parameter on text, password, path and autocomplete prompts, and document how to defer validation until submission. The default remains True. Both booleans and prompt_toolkit filters remain supported, including with prompt_toolkit 2.

Add 24 parametrized cases covering the signatures, filter forwarding, rejection of invalid submissions and validation timing during input. The timing tests use real prompt input pipes with dummy output; they are specific to prompt_toolkit 3's asyncio loop. Submission tests cover both supported prompt_toolkit major versions.

Validation on Windows:

  • Python 3.14.7 / prompt_toolkit 3.0.53: full suite, 194 passed, 94% overall statement coverage.
  • Python 3.12.10 / prompt_toolkit 2.0.10: full suite, 177 passed, 17 skipped (including the 8 new asyncio timing cases).
  • Python 3.12.10 / prompt_toolkit 3.0.52: mypy 1.16.1 passed on all 19 source files.
  • Black 23.3.0 (--target-version py310), isort 5.12.0, Flake8 7.1.0 and git diff --check passed for the changed files.

With mypy 2.4.0 and prompt_toolkit 3.0.53, both the unmodified base and this branch report the same four pre-existing PromptSession formatted-text argument errors. Those are outside this change. Linux and macOS have not been tested locally.

Checklist

  • I have read the Contributor's Guide.
  • Hosted PR checks have passed (pending their execution).

@Nagaraaa Nagaraaa closed this by deleting the head repository Nov 11, 2026
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