Skip to content

Odd error message for invalid use of tuple(): expected "Iterable[Never]" #19098

Open
@wyattscarpenter

Description

@wyattscarpenter

tuple(1) is invalid, of course. But what error message does it bring?

main.py:1: error: Argument 1 to "tuple" has incompatible type "int"; expected "Iterable[Never]"  [arg-type]

Well that's odd! Considering that it can take iterables of all sorts of things, and not... impossible things.

In fact, this has to be wrong, because when I make my own function with Iterable[Never] argument, it doesn't like taking iterables of other things

from typing import Iterable, Never

def f(a: Iterable[Never]) -> None:
    pass

f([1,2,3]) # main.py:6: error: Argument 1 to "f" has incompatible type "list[int]"; expected "Iterable[Never]"  [arg-type]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions