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

Erratic problem reporting in VSCode #4609

Open
Mapiarz opened this issue Jul 3, 2023 · 6 comments
Open

Erratic problem reporting in VSCode #4609

Mapiarz opened this issue Jul 3, 2023 · 6 comments
Assignees
Labels
needs decision Do we want this enhancement?

Comments

@Mapiarz
Copy link

Mapiarz commented Jul 3, 2023

Describe the bug
Sometimes Pylance + Pyright correctly report problems sometimes it doesn't. It's erratic. See video below.

Screencast.from.03.07.2023.10.54.02.webm

Keep in mind I'm not saving the file and there's no autosave enabled. I'm just typing in letter by letter and waiting to see what happens.

Expected behavior
I would expect the detected problems to always show up in the problems window.

VS Code extension or command-line
VS Code 1.78.2 with Pylance v2023.6.40

Additional context
I couldn't find any crashes or seemingly relevant infos in Python or Python Language Server outputs. Project running in a devcontainer. No extra formatting/linting extensions installed, just Python + Pylance.

How can I debug this?

@Mapiarz Mapiarz added the bug Something isn't working label Jul 3, 2023
@Mapiarz
Copy link
Author

Mapiarz commented Jul 3, 2023

I have some further insight.

I have multi workspace repo. Here's a simplified overview of my repo structure:

  • root
    • backend (all the python)
      • pyproject.toml
      • .vscode
        • settings.json
    • frontend (js etc.)
    • my_project.code-workspace

Now, given the above structure, I can set the typeCheckingMode in 3 different places. Turns out that if I do it via pyproject.toml or settings.json then I get the erratic behavior as shown in the OP. If I set it via my_project.code-workspace all is working as intended.

@GugelRobin
Copy link

I've had a similar problem as well.
The root cause is that for each workspace another pylance instance is created.
If you have an extra root workspace you'll have all files in backend being checked by two pylance instances. Both having different opinions on what the root of your project is.
Therefore your root pylance cannot import the BoatComponent from the specified import path, but your backend pylance can. When you make a code change you'll have a race condition. In the case you've shown in the video first your root pylance says "I don't know this property" and VS-Code draws red squiggles, afterwards your backend pylance says it's fine - the red squggles disappear.

My solution back then was adding a pyrightconfig.json file in root with exclude: ["**"] to prevent the root pylance from checking anything (there's no way to disable it - at least I wasn't able to...). Note that way I was required to add a pyrightconfig.json file in any other python project in the multi-workspace.

@Mapiarz
Copy link
Author

Mapiarz commented Jul 4, 2023

Thanks @GugelRobin, I was able to workaround this issue.

@Mapiarz Mapiarz closed this as completed Jul 4, 2023
@Mapiarz Mapiarz reopened this Jul 4, 2023
@Mapiarz
Copy link
Author

Mapiarz commented Jul 4, 2023

Actually I'm going to leave it open. This at least should be documented somewhere, right?

@erictraut erictraut added needs decision Do we want this enhancement? and removed bug Something isn't working labels Jul 13, 2023
@rchiodo rchiodo transferred this issue from microsoft/pyright Jul 14, 2023
@rchiodo
Copy link
Contributor

rchiodo commented Jul 14, 2023

Transferring to Pylance. We may want to show something special in this case:

  • User has overlapping folders open
  • User has different settings for each folder

@luabud
Copy link
Member

luabud commented Jul 14, 2023

Related to microsoft/vscode-python#21204

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs decision Do we want this enhancement?
Projects
None yet
Development

No branches or pull requests

6 participants