Skip to content

decorator that uses paramspec breaks generics on decorated function #2336

@DetachHead

Description

@DetachHead

Summary

from collections.abc import Callable

def fn[**P, T](value: Callable[P, T]) ->  Callable[P, T]:
    return value

@fn  # errors go away when this decorator is removed
def foo[T](value: T) -> T:
    return value

a: int = foo(1) # errors
Object of type `T@foo` is not assignable to `int` (invalid-assignment) [Ln 10, Col 10]
Argument is incorrect: Expected `T@foo`, found `Literal[1]` (invalid-argument-type) [Ln 10, Col 14]

https://play.ty.dev/a7e1e83f-6c64-4c50-bf7d-fc7e32fccee8

Version

ty 0.0.8 (aa7559d 2025-12-29)

Metadata

Metadata

Assignees

Labels

callablesgenericsBugs 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