Skip to content

Conversation

@stgraham2000
Copy link

If the passed in default is a string but the type parameter is not a string then click should do its best to convert the default to the requested type.

This becomes an issue when using mypy with click. MyPy will complain if you pass anything but a string for the default. One option is to do a type ignore but that starts to pollute the code quickly if you have a lot of prompts that expect integer values. Fixing this also will prevent some accidental bugs where you use different types with your type option and your default. Click should do its best to honor the requested type.

@davidism davidism added the f:prompt feature: prompt for input label Aug 9, 2020
@davidism davidism added this to the 8.0.0 milestone Oct 14, 2020
@davidism
Copy link
Member

davidism commented Oct 14, 2020

Looks like there was already a special check for the Path type, but it doesn't seem like there was any reason to restrict it to that type, so I simplified it. It was probably because not all types were able to pass through a value that was already the correct type, but that was fixed in #1649 #1687.

@davidism davidism merged commit 801a29f into pallets:master Oct 14, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

f:prompt feature: prompt for input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants