Skip to content

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

@WillDuke

Description

@WillDuke

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggenericsBugs or features relating to ty's generics implementation

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions