Open MarcoGorelli opened 5 months ago
Within vscode with pylance it seems to work for me:
Yeah pylance seems more advanced. As much as I'd like to say "everyone should just use vscode or pycharm", people don't necessarily have control over what they use (especially at work)
from discussion: it's desirable to make this work, it's just not clear what exactly is the culprit
Description
I'd brought up some time ago that auto-complete is unreliable in IPython. I thought this might have been due to limitations in recognising namespaces (like
.dt
). However, comparing with the much simpler Narwhals, that seems to not the case:Let's see what happens if I type
pl.col('a').dt.to
- what's suggested?demo from IPython:
Narwhals (correct suggestion):
Polars (incorrect suggestion):
From nvim (with pylsp):
Narwhals (correct suggestion):
Polars (no suggestion):
I suspect (though haven't yet been able to verify) that some of the magic dispatch mechanisms in Polars may be to blame? They work fine at runtime, but mess up editors
If that's the case, then I'd advocate for drastically simplifying things on the Python Polars side - if that means copy-and-pasting a few definitions, then OK, so be it. But in terms of user adoption, a better user experience with auto-complete would really pay dividends
Note that the namespaces aren't the only cases where the discrepancy appears. I won't post screenshots, but you can verify that typing
pl.col('a').fi
/nw.col('a').fi
gives:fill_null
andfilter
A solution could be to say that IPython and pylsp are wrong...but given how many users they have (especially the former, almost the whole data science world uses some variation of it...) I think it'd be a pity