You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import pandas as pd
def x():
res = pd.DataFrame([1, 2, 3])
res["mean"] = [None] * 3
reveal_type(res["mean"])
This will currently produce something like list[None], but that's incorrect because DataFrames return Series objects from __getitem__. Mypy and pyright get this right, so it may be worth looking into what heuristics they are using.
Solution I can think of: currently NameCheckVisitor.composite_from_subscript sets the narrowed type, regardless of the type of the subscripted object. If we instead did this in list.__setitem__ and dict._setitem__ (where we know it's safe), that would solve the problem.
The text was updated successfully, but these errors were encountered:
This will currently produce something like
list[None]
, but that's incorrect because DataFrames return Series objects from__getitem__
. Mypy and pyright get this right, so it may be worth looking into what heuristics they are using.Solution I can think of: currently
NameCheckVisitor.composite_from_subscript
sets the narrowed type, regardless of the type of the subscripted object. If we instead did this inlist.__setitem__
anddict._setitem__
(where we know it's safe), that would solve the problem.The text was updated successfully, but these errors were encountered: