-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
stubs: false positiveType checkers report false errorsType checkers report false errors
Description
Install dependencies:
$ pip install click mypy
$ mypy --version
mypy 0.641
$
Create example.py:
from typing import Sequence, Union
import click
def my_callback(
ctx: click.core.Context,
param: Union[click.core.Option, click.core.Parameter],
value: Sequence[Union[int, bool, str]],
):
print('Value is: ' + str(value))
@click.command('example')
@click.option('-x', multiple=True, callback=my_callback)
def example(x):
pass
if __name__ == '__main__':
example()Run this to see that value is a tuple:
$ python example.py
Value is: ()
$
Run mypy which incorrectly tells us that value must be Union[bool, int, str]:
$ mypy example.py
example.py:13: error: Argument "callback" to "option" has incompatible type "Callable[[Context, Union[Option, Parameter], Sequence[Union[int, bool, str]]], Any]"; expected "Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], Any]]"
Metadata
Metadata
Assignees
Labels
stubs: false positiveType checkers report false errorsType checkers report false errors