pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

Don't show errors in stdlib files

Open mjbvz opened this issue 1 year ago • 12 comments

  1. Turn on analysis
  2. Run go to definition on join from os.path

Bug My problem count explodes:

Image

I wouldn't expect analysis to kick in for files from the standard library like this

mjbvz avatar Sep 24 '24 23:09 mjbvz

I would hazard a guess that you have a pyproject.toml or a pyrightconfig.json? The errors are likely a result of this: https://github.com/microsoft/pylance-release/wiki/Settings.json-overridden-by-Pyrightconfig.json-or-Pyproject.toml

It's forcing your typecheckingmode to default to 'basic'

rchiodo avatar Sep 25 '24 16:09 rchiodo

I'm pretty sure I just turned on type checking from the language status menu. I don't see those files in my project

Image

mjbvz avatar Sep 25 '24 16:09 mjbvz

That's expected behavior then. typeCheckingMode applies to all open files, regardless of if they're under a workspace folder or not.

What you're asking for is typechecking only on 1st party source and not 3rd party source it seems like? Seems reasonable to me. Why would anybody care to type check code that isn't their own?

rchiodo avatar Sep 25 '24 16:09 rchiodo

One way to workaround this is to add a glob to the 'ignore' setting:

"python.analysis.ignore": ["${workspaceFolder}/venv/**/*"]

rchiodo avatar Sep 25 '24 16:09 rchiodo

Maybe we should add all of the site-packages folders to the default ignore list?

rchiodo avatar Sep 25 '24 17:09 rchiodo

we show errors from any file opened in vscode. if your go to def opened a file, we will show errors on that file as long as it stays as open. once you close that file, they will go away. and that behavior is by design to support orphan files opened in editor along with folder

you could request enhancement request though. and we see how many upvote we get.

heejaechang avatar Sep 25 '24 17:09 heejaechang

Feels like this scenario is common enough that ignoring the standard library would be a reasonable default. When would you want these errors to show up?

mjbvz avatar Sep 25 '24 17:09 mjbvz

standard library typeshed authors? it would be nice to have a way to categorize problems in UI. so less important errors can group differently than other more important errors.

heejaechang avatar Oct 03 '24 19:10 heejaechang

standard library typeshed authors?

Having an option (with no errors reported by default) seems reasonable for the majority of users

mjbvz avatar Oct 03 '24 20:10 mjbvz

we could add an option for it, but usually user doesn't leave stdlib file open for long time? they usually either open it to see some definition/signature and close it. what is the scenario where you leave them open for long time?

heejaechang avatar Oct 03 '24 20:10 heejaechang

Yes that's exactly the problem I ran into:

  1. Run go to def on stdlib symbol to quickly browse the code
  2. File opens and I am flooded with 100+ errors
  3. The errors do go away after I close the file but it's distracting to suddenly have that many errors appear and also distracting to see all the red lines highlighted in the stdlib file

mjbvz avatar Oct 03 '24 20:10 mjbvz

I would love to see everything in stdlib/venv get excluded. It's just pointless distraction.

Ravencentric avatar Oct 04 '24 08:10 Ravencentric

I'm struggling to configure VS Code to ignore the errors from the stdlib.

I have this in settings.json:

"python.analysis.ignore": [
    "${workspaceFolder}/.venv",
    "**/python3.*"
],

The errors are showing up in files with paths like: /opt/homebrew/Cellar/[email protected]/3.11.9_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/typing.py

(.venv/bin/python is a symlink to /opt/homebrew/Cellar/[email protected]/3.11.9_1/Frameworks/Python.framework/Versions/3.11/bin/python3.11)

I'd like to not hard-code python3.11 or homebrew in the settings, ideally.

Any tips?

garymm avatar Dec 17 '24 19:12 garymm