Skip to content

click.prompt combined with click.Path skips path validation for prompt default #795

@JWCook

Description

@JWCook

If using click.prompt with both click.Path and a default value, any user input will be validated through click.Path, but the default value will not be.

Example:

>>> import click
>>> click.prompt('Path', type=click.Path(exists=True), default='/invalid/path')
# Invalid user input raises error
Path [/invalid/path]: /some/other/invalid/path
Error: Path "/some/other/invalid/path" does not exist.
# Invalid default value does not raise error
Path [/invalid/path]:
'/invalid/path'

Tested with click 6.7, and python 2.7.13 and 3.6.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions