Interaction between "exclude" and LSP suggestions #7984
Replies: 2 comments 3 replies
-
Yes, this is by design. If you exclude a file, you're telling pyright (or pylance) that the file shouldn't be considered part of your project. It will no longer analyze that file (unless it happens to be imported by one of the files in your project), and it will no longer include that file in operations like auto-import or project-wide replace. The "ignore" configuration setting may solve your problem. With this option, the files are still considered "part of the project" and are still analyzed, but all diagnostics for those files are suppressed. Does that meet your needs? You may also be interested in this feature request which I just opened for reconsideration. If this is something you're interested in, please upvote it. |
Beta Was this translation helpful? Give feedback.
-
Thanks Eric for your reply, it is much appreciated.
Huh, the documentation makes it seem the other way around: exclude removes the file from analysis except if it's included by an included flie while ignore removes the file from analysis even if it's included? I tested it and you are right, however. "Ignore" makes the symbols of the file show up in the LSP, whereas with "exclude" they are missing.
It does analyze it however. When I open any excluded file it is analyzed and errors show as usual, even if it is not referenced from any included file. However, if I add the file to So I find the current behavior very confusing since neither option is really a superset of the other: |
Beta Was this translation helpful? Give feedback.
-
I'm creating a pyrightconfig.json for our moderately sized python project. This configuration will be used by CI to enforce that all included files type check cleanly. Since getting the entirely codebase clean is a herculean task I'm doing it incrementally: I
include
**/*.py
but thenexclude
(in the config) a list of specific files that currently do not type check. I have tooling which detects if an excluded file actually became clean and so it can be removed.What I noticed, however, is that putting a file in the "exclude" array in pyrightconfig.json prevents classes it contains from being auto-suggested as completions in other files (in vscode), prevents it from showing up in the "all symbols" listing, etc. I.e., it is mostly ignored by the LSP.
Is this by design? I just want to exclude these files form being part of the type set checked when I run pyright but I don't want to exclude them from the LSP entirely! It is seems clear that they are actually analyzed as if I use classes from the excluded I get analysis for them (e.g., if I use a non-existing attribute I am warned about it). If I open an excluded file in the editor it is type checked.
Is there any workaround here? I suppose I could maintain a different pyright config specifically for CLI use in CI, but nearly all of the other settings (e.g., which checks are enabled) I do want to share for consistency between IDE use and CLI use.
Beta Was this translation helpful? Give feedback.
All reactions