ty icon indicating copy to clipboard operation
ty copied to clipboard

No error reported for incorrect arguments passed to function generic over a `ParamSpec`

Open WillDuke opened this issue 3 weeks ago • 6 comments

Summary

ty no longer raises a diagnostic on this code:

from typing import ParamSpec, TypeVar, Callable

P = ParamSpec("P")
T = TypeVar('T')

def fn(p1: int, p2: int):
    ...

def submit(fn: Callable[P, T], *args: P.args, **kwargs: P.kwargs):
    ...

submit(fn, p1=1, p2="wrong")

Here's the link to the playground with the above snippet.

Here's a motivating example where this comes up (link).

from concurrent.futures import ThreadPoolExecutor



def fn(p1: int, p2: int):
    ...

with ThreadPoolExecutor() as executor:
    executor.submit(fn, p1=1, p2="wrong")

I was originally going to submit this issue because I noticed that the diagnostic gave (what I think is) the correct error but highlighted p1 instead of p2, but as of today the diagnostic no longer appears at all.

Here's the original diagnostic issue using ty as built into Zed, updated yesterday. (Notice the 1 is underlined instead of "wrong".)

Image

Version

main (2a61fe235)

WillDuke avatar Dec 17 '25 14:12 WillDuke

Thanks for the report! I'm not totally sure that this ever worked -- I think the error you were seeing before was an unrelated bug 😆

But it definitely should work, agreed!

AlexWaygood avatar Dec 17 '25 14:12 AlexWaygood

Thanks, the original error fooled me into thinking this was already supported!

WillDuke avatar Dec 17 '25 14:12 WillDuke

@dhruvmanila, is this related to the last bullet point in https://github.com/astral-sh/ty/issues/1861?

AlexWaygood avatar Dec 17 '25 16:12 AlexWaygood