Diagnostics from ignored/excluded paths are reported #2697
Replies: 5 comments
-
The pyrightconfig.json is meant to configure the settings for a specific workspace, and most of the paths within it are assumed to be relative to your workspace root directory. This is true of the "include", "exclude" and "ignore" configuration options. If you open the Output tab and choose "Pyright" (or "Pylance"), you should see an error that says something like:
The other paths you've specified ( It looks like you are opening a file outside of your workspace, so the "ignore" setting doesn't apply to it. When you open a file outside of your workspace, pyright will still analyze it and report errors on it. I'd like to understand your use case a bit better because it sounds like you're using it in a way that I didn't anticipate when I implemented the "ignore" configuration option in pyrightconfig.json.
|
Beta Was this translation helpful? Give feedback.
-
I'm opening source files outside of my workspace for two reasons: A more detailed analysis of why this happens is that probably both the execution of code and resolving of symbol definitions make use of Don't get me wrong, this may simply be misunderstanding of the tools I'm using, rather than necessarily a problem with pyright. I think I should avoid python from resolving packages from my global python. But of course without breaking the global python, but that requires effort and understanding of how to achieve so, and that it is a problem in the first place. I'm not aware of how to prevent vscode from resolving source files in a particular directory. In runtime it could be resolved with something I want to suppress the diagnostics of these files because they show up in vscode and they are noise. Since they are not diagnosing my code, I'm not interested in the diagnostics; they're intended for somebody who could fix them, i.e. library authors. The diagnostics are noise because they obscure finding my own diagnostics. Some library files really drown out those reported on my own files. Closing the files is obviously what I then have to manually resort to. Also suppose you're in the workflow of having coded something and you're about to commit, but you need to tidy everything up such that it'll pass automated formatting and linters, then I typically press the keyboard shortcut for the vscode command This is not checked into or shared with other developers, mostly for non-technical reasons, but aside from those, source files resolution or Thank you, and hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the additional details. I understand your use case better now. The It sounds like what you really want is some global setting that indicates that you never want to see any errors for code files outside of your workspace regardless of their path. I think the best thing to do here is to transfer this issue to the pylance repo. It's not really a core type checking issue and is related more to the language server functionality and settings. I'd like to get input from the broader pylance team to see if they have any better suggestions for how to address this use case. It would also be interesting to hear from other users if they have a similar need. |
Beta Was this translation helpful? Give feedback.
-
I have this exact same issue and it is very frustrating. Specifically, sometimes I need to open up files from other packages in my environment (poetry) to see what they're doing, troubleshooting etc. I have no control over their type checking/formatting etc so I'd like to be able to just view them without 100 red problems being shown. |
Beta Was this translation helpful? Give feedback.
-
Moving this issue to discussion as an enhancement request for comments and upvotes. |
Beta Was this translation helpful? Give feedback.
-
Bug description
Diagnostics are reported for files matching
ignore
andexclude
inpyrightconfig.json
.I'm trying to prevent diagnostics to appear in vscode Problems output in (base) library code. I can't seem to exclude/ignore the
io.py
file, as you can see in the screenshot below.To Reproduce
Exclude the base python installation path in the
pyrightconfig.json
, like in the screenshot.Open a file from the base python installation in Windows.
Observe the reported diagnostics.
Expected behavior
No diagnostics to show up for the file.
Screenshot of behavior
Things to note in the screenshot:
C:\Program Files\Python38\lib\io.py
io.py
) is open (as you can see in the top).VS Code extension
I use pyright through the extension Pylance, but I don't think it's Pylance-specific.
Extra information
I've tried all sorts of combinations of glob patterns/full path, and path separators.
I've paid attention to case-sensitivity of the paths (even though I'm on windows).
I've restarted vscode plenty.
The diagnostics in the screeenshot were reported in all cases.
Beta Was this translation helpful? Give feedback.
All reactions