Closed
Description
This is a follow-up for #3132 (this does not happen on master).
Consider this example found by @JukkaL in #3132:
from typing import Mapping, Any
import sqlite3
class dict_like_row(sqlite3.Row, Mapping[str, Any]):
def f(self) -> None:
d = dict(self) # Need type annotation for variable <--- wasn't required before
It looks like this problem appears because sqlite3.Row
has an untyped __iter__
and it is therefore considered a subtype of Iterable
protocol and therefore matches another overload of dict
constructor (annotating Row.__iter__
fixes the problem).
It is not clear what is the right way here, maybe we can somehow tweak overload similarity in case of an unsuccessful inference (here e.g. Tuple[KT, VT]
never matches Any
).