Odd error message for invalid use of tuple(): expected "Iterable[Never]"
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
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]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the diagnostic in main.py with tuple(1), then compare it with the Iterable[Never] example shown in the issue. Trace the type information used for tuple() and determine why its invalid argument is reported as Iterable[Never]; done means the diagnostic no longer presents that misleading expectation and relevant checks pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100