pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

Add config option to mark files as not reachable

Open correctmost opened this issue 4 months ago • 18 comments

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.py to trigger warnings about the language server crashing
    • Note: pyrefly check does not crash with the same folder

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

correctmost avatar Aug 02 '26 01:08 correctmost

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.

connernilsen avatar Aug 30 '26 01:08 connernilsen

#claim

obassett avatar Aug 30 '26 03:08 obassett

@obassett you've claimed this issue — it's now assigned to you. Thanks for picking it up! 🎉

github-actions[bot] avatar Aug 30 '26 03:08 github-actions[bot]

#claim

jny0444 avatar Sep 07 '26 18:09 jny0444

@jny0444 this issue is already claimed by @obassett. Please coordinate with them before starting.

github-actions[bot] avatar Sep 07 '26 18:09 github-actions[bot]

@obassett hi, are you still working on the issue or can we work together on this issue?

jny0444 avatar Sep 09 '26 16:09 jny0444

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.

obassett avatar Sep 15 '26 22:09 obassett

#unclaim

obassett avatar Sep 15 '26 22:09 obassett

@obassett you've been unassigned from this issue. Thanks for letting us know! 👋

github-actions[bot] avatar Sep 15 '26 22:09 github-actions[bot]

#claim

jny0444 avatar Sep 16 '26 02:09 jny0444

@jny0444 you've claimed this issue — it's now assigned to you. Thanks for picking it up! 🎉

github-actions[bot] avatar Sep 16 '26 02:09 github-actions[bot]

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.disableLanguageServices setting 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 avatar Sep 28 '26 22:09 kinto0

@kinto0 my thoughts are that "not reachable" -> "pyrefly should pretend this file does not exist". Is there other ambiguity you are concerned about?

connernilsen avatar Sep 29 '26 00:09 connernilsen

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.

kinto0 avatar Sep 29 '26 00:09 kinto0

  • we have a python.pyrefly.disableLanguageServices setting 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.

correctmost avatar Sep 29 '26 04:09 correctmost

@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.

connernilsen avatar Oct 02 '26 21:10 connernilsen

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.

shahhamdihassan avatar Oct 19 '26 13:10 shahhamdihassan

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!

github-actions[bot] avatar Nov 03 '26 00:11 github-actions[bot]