Does Pylance just not work with Cursor? How to get imports in quick fix menu?

I’m so confused. I had to reinstall windows so I exported my profile. Before the reinstall, I could use pylance (unless I’m losing my mind here) and use the quick fix box to fix import errors by importing the code in question. Now after the reinstall pylance doesn’t work and reading the forum threads it seems like it shouldn’t have been working before for me either. Jedi and Pyright, from what I can tell, do not have the imports-in-quick-fix-box feature so I’m not sure what to do here as I can’t program without this.

Did I hallucinate pylance working? I was on the same cursor version yesterday on the old OS install, not like it was 6 months ago.

Edit: Seems like what’s likely the case is that the version of pylance I had installed was a release prior to Microsofts decision to not allow its usage outside of VS code. I found some possible fixes here that can hopefully be applied to cursor too:

Edit2: the above fixes didnt work for me but I found a fork of pyright that has a lot of the pylance features including the one I needed in case anyone else stumbles upon this thread:
https://open-vsx.org/extension/detachhead/basedpyright

2 Likes

Looking at my Python Cursor setup now I see that I’m using Pylance v2023.10.40.

A question for the Cursor folks - is that currently the recommending solution: to just keep using that version?

Or should we be using the Open VSX ‘BasedPyright’ extension that you’ve linked above?

I’m finding Cursor to be valuable but the bugginess/quirkiness is a bit disturbing so I want to stay on a beaten path as much as possible.

1 Like

This issue still persists with v0.42.3 today.

1 Like

I’ve been using basedright since I made the OP and it’s working well for my needs. The cursor team really needs to clarify this issue though, pretty big miss imo.

1 Like

+1 on the above. I really like cursor, but missing pylance is enough for me to question the decision to switch. I’m confused because it “kind of” works? I see logs in the language server without any errors:

2024-11-23 08:38:50.710 [info] (Client) Pylance async client (2024.8.1) started with python extension (2024.12.3)
2024-11-23 08:38:51.094 [info] [Info  - 8:38:51 AM] (7611) Pylance language server 2024.8.1 (pyright version 1.1.373, commit ee424479) starting
2024-11-23 08:38:51.094 [info] [Info  - 8:38:51 AM] (7611) Server root directory: file:///Users/tomassantos/.cursor/extensions/ms-python.vscode-pylance-2024.8.1/dist
2024-11-23 08:38:51.098 [info] [Info  - 8:38:51 AM] (7611) Starting service instance "skynet"
2024-11-23 08:38:51.130 [info] [Info  - 8:38:51 AM] (7611) Setting pythonPath for service "skynet": "/Users/tomassantos/.pyenv/versions/skynet/bin/python"
2024-11-23 08:38:51.130 [info] [Info  - 8:38:51 AM] (7611) Setting environmentName for service "skynet": "3.11.9 (skynet venv)"
2024-11-23 08:38:51.130 [info] [Info  - 8:38:51 AM] (7611) Loading pyproject.toml file at /Users/tomassantos/Documents/dagster/skynet/pyproject.toml
2024-11-23 08:38:51.132 [info] [Info  - 8:38:51 AM] (7611) Pyproject file "/Users/tomassantos/Documents/dagster/skynet/pyproject.toml" has no "[tool.pyright]" section.
2024-11-23 08:38:51.132 [info] [Info  - 8:38:51 AM] (7611) No include entries specified; assuming /Users/tomassantos/Documents/dagster/skynet
2024-11-23 08:38:51.132 [info] [Info  - 8:38:51 AM] (7611) Auto-excluding **/node_modules
2024-11-23 08:38:51.132 [info] [Info  - 8:38:51 AM] (7611) Auto-excluding **/__pycache__
2024-11-23 08:38:51.133 [info] [Info  - 8:38:51 AM] (7611) Auto-excluding **/.*
2024-11-23 08:38:51.150 [info] [Info  - 8:38:51 AM] (7611) Assuming Python version 3.11.9.final.0
2024-11-23 08:38:51.287 [info] [Info  - 8:38:51 AM] (7611) Found 30 source files
2024-11-23 08:38:51.444 [info] [Info  - 8:38:51 AM] (7611) Background analysis(1) root directory: file:///Users/tomassantos/.cursor/extensions/ms-python.vscode-pylance-2024.8.1/dist
2024-11-23 08:38:51.444 [info] [Info  - 8:38:51 AM] (7611) Background analysis(1) started
2024-11-23 08:38:51.800 [info] [Info  - 8:38:51 AM] (7611) Indexer background runner(2) root directory: file:///Users/tomassantos/.cursor/extensions/ms-python.vscode-pylance-2024.8.1/dist (index)
2024-11-23 08:38:51.800 [info] [Info  - 8:38:51 AM] (7611) Indexing(2) started
2024-11-23 08:38:52.440 [info] [Info  - 8:38:52 AM] (7611) scanned(2) 127 files over 1 exec env
2024-11-23 08:38:52.598 [info] [Info  - 8:38:52 AM] (7611) indexed(2) 97 files over 1 exec env
2024-11-23 08:38:52.628 [info] [Info  - 8:38:52 AM] (7611) Indexing finished(2).

And I see the little red lines with errors like:

"partition_date_str" is not definedPylancereportUndefinedVariable

but I notice that there is a big delay between making changes and seeing the pylance error indications go away. Also using “CMD+.” to import missing functions / variables hangs every time.

Can the team please clarify what users are supposed to do here?