Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Simplify expressions definition to enable better auto-complete in IPython + nvim #16933

Open
MarcoGorelli opened this issue Jun 13, 2024 · 3 comments
Labels
accepted Ready for implementation enhancement New feature or an improvement of an existing feature

Comments

@MarcoGorelli
Copy link
Collaborator

MarcoGorelli commented Jun 13, 2024

Description

I'd brought up some time ago that autocomplete / tab-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):

Screenshot 2024-06-13 145708

Polars (incorrect suggestion):

image


From nvim (with pylsp):

Narwhals (correct suggestion):

image

Polars (no suggestion):

image


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:

  • IPython:
    • Narwhals: suggests fill_null and filter
    • Polars: no suggestion EDIT: this is now fixed in Polars (but the pl.col('a').dt.to issue is still present!)
  • nvim:
    • this works for both 👍

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

@MarcoGorelli MarcoGorelli added the enhancement New feature or an improvement of an existing feature label Jun 13, 2024
@kszlim
Copy link
Contributor

kszlim commented Jun 14, 2024

Within vscode with pylance it seems to work for me:

image

@MarcoGorelli
Copy link
Collaborator Author

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)

@stinodego stinodego added the needs triage Awaiting prioritization by a maintainer label Jun 14, 2024
@MarcoGorelli MarcoGorelli added accepted Ready for implementation and removed needs triage Awaiting prioritization by a maintainer labels Jul 12, 2024
@github-project-automation github-project-automation bot moved this to Ready in Backlog Jul 12, 2024
@MarcoGorelli
Copy link
Collaborator Author

from discussion: it's desirable to make this work, it's just not clear what exactly is the culprit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation enhancement New feature or an improvement of an existing feature
Projects
Status: Ready
Development

No branches or pull requests

3 participants