🌐 AI搜索 & 代理 主页
Skip to content

(🎁) Error messages for decorator applications have a very bad UX #16295

@KotlinIsland

Description

@KotlinIsland
from typing import Callable

def decorator(f: object) -> Callable[[Callable[[int], object]], None]: ...

def f(a: int) -> None: ...

@decorator(f)  # error: Argument 1 has incompatible type "Callable[[], Any]"; expected "Callable[[int], object]"  [arg-type]
def something(): ...

So the error is that the function something doesn't have the right type for the decorator, but the message is quite misleading, it reads like the error is with the call to decorator and f.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions