Skip to content

Incompatible return value type (got "function", expected "Callable[..., Any]") #12053

Closed
@gcaria

Description

@gcaria
import glob
from typing import Callable, List


def fun1(b: str) -> List[str]:
    return ["a", "b"] + [b]


def fun(a: str) -> Callable:
    return fun1 if a == "hello" else glob.glob

Running mypy (v 0.931) on this file gives:

error: Incompatible return value type (got "function", expected "Callable[..., Any]")  [return-value]

Crossposting from stackoverflow where an answer suggests that this problem is limited to using the ternary operator, but a bug nevertheless.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions