microsoft / pyright

Static Type Checker for Python
Other
13.32k stars 1.45k forks source link

Crash with ParamSpec and overloaded function involved #8823

Closed Azureblade3808 closed 2 months ago

Azureblade3808 commented 2 months ago

Describe the bug Following sample code is causing Pyright to crash. Although the code is not optimized, I think it should still be valid, and a crash is not expected.

The int in last line could be replaced with any overloaded function, and the crash would still occur.

Code or Screenshots

from typing import Any, Callable

def defer_callable[
    **P
](callable: Callable[P, Any]) -> DeferredCallable[Callable[P, None]]: ...

class DeferredCallable[_Callable_t]:
    def __init__(self, f: _Callable_t, /) -> None: ...
    def __call__[
        **P
    ](
        self: DeferredCallable[Callable[P, Any]], *args: P.args, **kwargs: P.kwargs
    ) -> None: ...

_ = defer_callable(int)(0)

VS Code extension or command-line Found with latest Pylance(Pyright 1.1.375) and verified that the issue still exists with Pyright 1.1.377.

erictraut commented 2 months ago

Thanks for the bug report. This will be addressed in the next release.

erictraut commented 2 months ago

This is addressed in pyright 1.1.378.