-
Notifications
You must be signed in to change notification settings - Fork 767
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
Ignore flag for files and folders #422
Comments
We already ignore these files for purposes of workspace symbols, and the rest of the analysis is lazy and will only load files as needed to analyze the code you've written. Workspaces that contain their virtual environments are the main thing that we test with ourselves as that's the most common setup. Can you describe what it is that isn't working about Pylance for you? Are you finding something to be slow? Are results showing up that shouldn't be there in a search? Are diagnostics appearing in the wrong files? |
Thanks for the quick reply, @jakebailey! I have VS Code 1.49.2 (latest release) open into a folder containing a Pylance appears to be analyzing this file. This happens for any |
Is your diagnostic mode set to "openFilesOnly"? That should be the default, though even in that mode I wouldn't expect it to behave this way. |
Yes, I have: |
Did you open that file, or does the diagnostic appear if you've only opened one of the files in your project that imports it? |
I did some digging and found a clue. It matters whether the file/module has been imported into the project. Open via file explorer: ❌ Pylance analyzes it |
This might be useful: the reports appear after I run unit tests from inside vscode. I use pytest. |
It would be great if we could have a setting for the analyzer to be a bit more selective about the paths that it analyzes. If providing an Its a testament to pylance's usefulness that the analyzer is too important for me to only run it against open files. This is a huge issue right now for our local deployments, which can generate thousands of files in a temporary |
You can already achieve this with an See #1150 for the request to add this as a VS Code configuration. |
As far as I'm concerned, the above two things cover this issue; anything else I think is a bug (but all of the comments from this thread are months old and likely do not reproduce). |
I'm the original submitter. This is still happening, including with Two other exclusions to consider:
|
I can't get this to work.
Tried |
This wouldn't make sense given the main purpose of a language server like Pylance is to do live analysis of unsaved files; otherwise we're going back in time to running pylint at the CLI on save.
I don't think that's right; people do typecheck these sorts of files (even notebooks, #1541). You can stick a
Can you restate what it is you're looking for? Are you trying to ensure that the files aren't analyzed in the workspace diagnostic mode, or are you trying to get diagnostics to not show up for these files ever? The latter won't be true for opened files, but we should never offer diagnostics up for unopened files if you're in the default openFile diagnostic mode. If you want to bulk ignore diagnostics for certain files, you can use |
I phrased this imprecisely. I meant to say files that have never been saved. It's common to paste WIP code snippets into a new file. Being snippets, they usually don't pass linting or typechecking. Pylance should skip these files.
The Interactive itself is being linted.
I would like for files in my virtualenv to never display diagnostics in the editor, while remaining available to Pylance to use for diagnostics in other files.
My project file should have a diagnostic error because I'm missing an argument. If I then Go To Definition (cmd+click) to read the 3rd party source, that file shouldn't display any diagnostics. |
Thanks. The behavior you're seeing with the venv is intended; when you jump to a file, we reveal the diagnostics for it, then when it's closed, they disappear. Most users don't hit this because the default type checking mode in Pylance is "off". If you don't want to ever show diagnostics for these files, then You can use |
Thanks for the thorough response, I'll take |
Yes, if you have type checking enabled. It looks like you've enabled the "strict" mode, which is going to strongly complain about missing stubs (if the library is not |
It's very common to have a virtualenv folder in a project directory. Python files in a virtualenv should be skipped by Pylance, either by default (
.venv
,site-packages
, etc) or via a configurable ignore/exclude setting.The text was updated successfully, but these errors were encountered: