Skip to content

Decorator function annotated with Callable + TypeVar cannot be used #2118

@bluetech

Description

@bluetech

Describe the Bug

This is similar to #1555, however the commit 59098f4 included in 0.48.0 did not resolve the issue as I encounter it. Please see the unexpected error below, I tried to minimize it (see https://github.com/typeddjango/django-stubs/blob/f788f6ce9833c6805bad7a3cd19c77893b9f9063/django-stubs/views/decorators/http.pyi for the real definition of require_GET).

from collections.abc import Callable
from typing import Any, TypeVar

F = TypeVar("F", bound=Callable[..., Any])

require_GET: Callable[[F], F]

@require_GET
def view() -> Any: ...

Error:

ERROR Argument `() -> Any` is not assignable to parameter with type `TypeVar[F]` [bad-argument-type]
 --> x.pyi:8:1
  |
8 | @require_GET
  | ^^^^^^^^^^^^
  |

Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIIANCGQE4xhSmEAuuAtlBQMQAEABVIMmpPmix58fAMa50kAOYBXOqlYR5hADrp%2BAZRgw%2BAC1aticRAHpr9Rs0K46i6zHTXMuGXGtyFECpqGvLWfGDOfKgAbqjQqNiwsvJKquqa6Hy4xCHocDroZKwm8gC00TB0cBl8ALx82iAAzIQAjABMjbrUIERkEBRgdJzJULAyufkJMnwQHMTOrHwAwqhjCbC6QyOspMQQ6Iqz84t8AILopFR8ACp7MABqqHS6ugBidbf3T3QAFI1vRrXPDKLC1VbrRIwADahDh1wupAAugBKV7oBgAR2UEAYAH0AOIAURuiBWaygGxh0LeSOutPRAAEsTj8cSbrpMIw%2BNEIDAAO6-FF8UoAPnOlzJcMIIAAvjRUBMIBU3tAYBQ%2BqQBrKgA

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions