I have a project that uses the latest version of mypy (0.910) and click (8.0.1). I am attempting to use click.prompt() and pass in the type argument but this is always causing mypy (with default settings) to find errors.
Here is an example:
import click
name = click.prompt('What is your name?', type=str)
age = click.prompt('What is your age?', type=int)
When I run mypy against this file, I get two errors:
main.py:2: error: Argument "type" to "prompt" has incompatible type "Type[str]"; expected "Optional[ParamType]"
main.py:3: error: Argument "type" to "prompt" has incompatible type "Type[int]"; expected "Optional[ParamType]"
To address these, I tried passing in some different values for type but to no avail (same issues all happen for int as well):
name = click.prompt('What is your name?', type=Optional[str])
# Returns error: Argument "type" to "prompt" has incompatible type "object"; expected "Optional[ParamType]"
name = click.prompt('What is your name?', type=StringParamType)
# Returns error: Argument "type" to "prompt" has incompatible type "Type[StringParamType]"; expected "Optional[ParamType]"
name = click.prompt('What is your name?', type=Optional[StringParamType])
# Returns error: Argument "type" to "prompt" has incompatible type "object"; expected "Optional[ParamType]"
Is this a bug or should I be providing something different to type?
Environment:
- Python version: 3.7.10
- Click version: 8.0.1
- mypy version: 0.910
I have a project that uses the latest version of mypy (0.910) and click (8.0.1). I am attempting to use
click.prompt()and pass in thetypeargument but this is always causing mypy (with default settings) to find errors.Here is an example:
When I run mypy against this file, I get two errors:
To address these, I tried passing in some different values for
typebut to no avail (same issues all happen forintas well):Is this a bug or should I be providing something different to
type?Environment: