Skip to content

Regression in 0.0.80: return type lost when passing one generic forwarding function to another #4508

Description

@jelle-openai

Summary

This passes with ty 0.0.79 and reports invalid-return-type with 0.0.80:

from collections.abc import Callable

def capybara[**P, T](fn: Callable[P, T], /, *args: P.args, **kwargs: P.kwargs) -> T:
    return fn(*args, **kwargs)

def agouti[**P, T](callable: Callable[P, T], *args: P.args, **kwargs: P.kwargs) -> T:
    return callable(*args, **kwargs)

def hutia(fn: Callable[[], str]) -> str:
    return capybara(agouti, fn)

Expected: hutia returns str. Both forwarding functions preserve the return type of their callback.

Actual: ty 0.0.80 infers T@agouti for the return expression.

Versions: 0.0.79 (b4cd792) and 0.0.80 (7fd8e15).

Version

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingparamspecParamSpec and Concatenate inference, forwarding, specialization, validation, and editor supportregressionPreviously working behavior has regressed

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions