Add config option to mark files as not reachable
Describe the Bug
I have a folder with some large generated files that I exclude via project-excludes. pyrefly check honors the setting, but pyrefly lsp does not seem to.
Here is a simplified example:
.
├── a.py
├── b.py
└── pyproject.toml
pyproject.toml
[tool.pyrefly]
search_path = [
'.'
]
project-excludes = [
'**/a.py',
]
a.py
# The crasher from https://github.com/facebook/pyrefly/issues/3670
[(c:=)for c+]
[(c:=)for]
b.py
# empty
Steps to reproduce
- Open the folder in VS Code
- Make sure the Pyrefly extension is activated
- Open
b.pyto trigger warnings about the language server crashing- Note:
pyrefly checkdoes not crash with the same folder
- Note:
Version info
- VS Code 1.127.0
- Pyrefly 1.2.0 extension (just the extension, no venv used)
Sandbox Link
No response
(Only applicable for extension issues) IDE Information
No response
Hey @correctmost, thanks for the report. project-excludes actually doesn't mark the files as non-reachable, it's more about excluding the file from the set we return type errors about (your project).
For the LSP specifically, we still want to attempt to provide language services on a given file, even if we won't type check it.
Fully marking files as non-reachable is a totally valid/useful thing to have in some cases though. We can also apply this to the IDE and have Pyrefly not attempt any resolution or language help at all. I'm going to rename this issue to be more about that, since it's something we can look at adding, though we'll have to come up with a good name for it to try and avoid extra confusion.
#claim
@obassett you've claimed this issue — it's now assigned to you. Thanks for picking it up! 🎉
#claim
@jny0444 this issue is already claimed by @obassett. Please coordinate with them before starting.
@obassett hi, are you still working on the issue or can we work together on this issue?
Hi @jny0444 - I was looking at it, but my schedule is making it a bit difficult to work on. I will free it up for you to look at.
#unclaim
@obassett you've been unassigned from this issue. Thanks for letting us know! 👋
#claim
@jny0444 you've claimed this issue — it's now assigned to you. Thanks for picking it up! 🎉
sorry, joining this conversation late. I don't think this request is spelled out clearly enough to be implemented yet.
- we have a
python.pyrefly.disableLanguageServicessetting in VSCode which turns off the IDE (this can be applied on certain workspace folders specifically) - we have project_excludes for disabling type errors
is this enough configuration to accomplish everything? I wonder what "not reachable" means and why that's relevant. maybe to exclude certain files due to crashes?
@kinto0 my thoughts are that "not reachable" -> "pyrefly should pretend this file does not exist". Is there other ambiguity you are concerned about?
pyrefly currently pretends this file doesn't exist on the CLI with project-excludes and in the IDE with python.pyrefly.disableLanguageServices. so the thought is another setting that controls them both exclusively?
when I hear "not reachable", I interpret it as not allowing indexing / importing but still serving requests if it's opened manually.
- we have a
python.pyrefly.disableLanguageServicessetting in VSCode which turns off the IDE (this can be applied on certain workspace folders specifically)
I have a tree like this:
.
├── .vscode
│ ├── settings.json
├── out
│ ├── generated_file_1.py
...
├── src
│ ├── app_code.py
...
├── test
│ ├── test_code.py
...
I filed this issue because I was surprised to see that the LSP process was spending minutes analyzing the files in out/, even though I had excluded them in project-excludes.
Is it possible to only exclude the out/ directory using "python.pyrefly.disableLanguageServices": true? I am using a single-folder workspace without any .code-workspace files.
maybe to exclude certain files due to crashes?
I used a crash in the bug report to make it easier to see that project-excludes files were being processed in the background. I think auto-generated files (like large schemas) might be a more common scenario than crashers.
@kinto0
pyrefly currently pretends this file doesn't exist on the CLI with
project-excludes... when I hear "not reachable", I interpret it as not allowing indexing / importing but still serving requests if it's opened manually.
This isn't true. project-excludes only configures what Pyrefly will type check (specifically by fine-tuning the project-includes), so it's more like filtering entrypoints in where Pyrefly starts its check. We currently don't have a setting that can be set in the config to tell Pyrefly "this file does not exist to you".
That also means that a file in project-excludes won't be indexed by default, but can be if it's imported by something.
The language server crash in the example above (the a.py crasher from #3670) is fixed by the change for that issue, and the server will stay up once it lands. The config option to mark files as not reachable is still open here.
This issue has someone assigned, but has not had recent activity for more than 2 weeks.
If you are still working on this issue, please add a comment so everyone knows. Otherwise, please comment #unclaim to unassign yourself.
Thank you for your contributions!