pyre-check
pyre-check copied to clipboard
Callable with variadic args does not accept function with `*args: int`
The following example...
from typing import Callable
from pyre_extensions import TypeVarTuple, Unpack
Ts = TypeVarTuple('Ts')
def foo(func: Callable[[Unpack[Ts]], None]):
pass
def bar(*args: int):
pass
foo(bar)
...should type-check correctly; foo
expects a function with a single variadic argument, and that's exactly what bar
is. But Pyre (0.9.10) says:
test.py:12:4 Incompatible parameter type [6]:
In call `foo`, for 1st positional only parameter expected
`typing.Callable[[Variable(*test.Ts)], None]` but got
`typing.Callable(bar)[[Variable(int)], typing.Any]`.
It works if *args
isn't annotated:
def bar(*args):
pass
It also works if *args
is annotated as explicitly variadic:
def bar(*args: Unpack[tuple[int, ...]]):
pass
So I'm guessing this is some kind of bug with the logic for determining whether *args
is variadic or not...?
(@pradeep90, I'm guessing this is best addressed by you.)
@mrahtz Yes, this is a bug. We don't treat them as identical. Will fix.