ruff/crates
Dhruv Manilawala 66fc7c8fc0
Consider virtual path for various server actions (#18910)
## Summary

Ref:
https://github.com/astral-sh/ruff/issues/14820#issuecomment-2996690681

This PR fixes a bug where virtual paths or any paths that doesn't exists
on the file system weren't being considered for checking inclusion /
exclusion. This was because the logic used `file_path` which returns
`None` for those path. This PR fixes that by using the
`virtual_file_path` method that returns a `Path` corresponding to the
actual file on disk or any kind of virtual path.

This should ideally just fix the above linked issue by way of excluding
the documents representing the interactive window because they aren't in
the inclusion set. It failed only on Windows previously because the file
path construction would fail and then Ruff would default to including
all the files.

## Test Plan

On my machine, the `.interactive` paths are always excluded so I'm using
the inclusion set instead:

```json
{
  "ruff.nativeServer": "on",
  "ruff.path": ["/Users/dhruv/work/astral/ruff/target/debug/ruff"],
  "ruff.configuration": {
    "extend-include": ["*.interactive"]
  }
}
```

The diagnostics are shown for both the file paths and the interactive
window:

<img width="1727" alt="Screenshot 2025-06-24 at 14 56 40"
src="https://github.com/user-attachments/assets/d36af96a-777e-4367-8acf-4d9c9014d025"
/>

And, the logs:

```
2025-06-24 14:56:26.478275000 DEBUG notification{method="notebookDocument/didChange"}: Included path via `extend-include`: /Interactive-1.interactive
```

And, when using `ruff.exclude` via:

```json
{
	"ruff.exclude": ["*.interactive"]
}
```

With logs:

```
2025-06-24 14:58:41.117743000 DEBUG notification{method="notebookDocument/didChange"}: Ignored path via `exclude`: /Interactive-1.interactive
```
2025-06-24 12:24:28 +00:00
..
ruff Unify OldDiagnostic and Message (#18391) 2025-06-19 09:37:58 -04:00
ruff_annotate_snippets
ruff_benchmark [ty] Add Tanjun benchmark (#18850) 2025-06-21 18:29:02 +02:00
ruff_cache
ruff_db [ty] Add more benchmarks (#18714) 2025-06-18 13:41:38 +02:00
ruff_dev
ruff_diagnostics
ruff_formatter
ruff_graph fix casing of analyze.direction variant names (#18892) 2025-06-23 14:30:30 +02:00
ruff_index
ruff_linter [ruff] Trigger RUF037 for empty string and byte strings (#18862) 2025-06-24 08:26:28 +02:00
ruff_macros Unify OldDiagnostic and Message (#18391) 2025-06-19 09:37:58 -04:00
ruff_notebook
ruff_options_metadata
ruff_python_ast [ruff] Trigger RUF037 for empty string and byte strings (#18862) 2025-06-24 08:26:28 +02:00
ruff_python_ast_integration_tests
ruff_python_codegen
ruff_python_formatter [pylint] Supress PLE2510/2512/2513/2514/2515 autofix if the text contains an odd number of backslashes (#18856) 2025-06-23 10:11:51 +02:00
ruff_python_index
ruff_python_literal
ruff_python_parser Disallow newlines in format specifiers of single quoted f- or t-strings (#18708) 2025-06-18 14:56:15 +02:00
ruff_python_resolver
ruff_python_semantic [flake8-comprehensions] Handle template strings for comprehension fixes (#18710) 2025-06-19 16:23:46 -05:00
ruff_python_stdlib
ruff_python_trivia
ruff_python_trivia_integration_tests
ruff_server Consider virtual path for various server actions (#18910) 2025-06-24 12:24:28 +00:00
ruff_source_file
ruff_text_size
ruff_wasm Unify OldDiagnostic and Message (#18391) 2025-06-19 09:37:58 -04:00
ruff_workspace Unify OldDiagnostic and Message (#18391) 2025-06-19 09:37:58 -04:00
ty [ty] Support --python=<symlink to executable> (#18827) 2025-06-21 20:28:47 +01:00
ty_ide [ty] Include imported sub-modules as attributes on modules for completions (#18898) 2025-06-23 12:48:16 -04:00
ty_project [ty] Add more benchmarks (#18714) 2025-06-18 13:41:38 +02:00
ty_python_semantic [ty] Introduce UnionType::try_from_elements and UnionType::try_map (#18911) 2025-06-24 12:09:02 +00:00
ty_server
ty_test Remove extra dot in rule documentation (#18871) 2025-06-23 00:33:21 +00:00
ty_vendored
ty_wasm