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 Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_benchmark [ty] Add Tanjun benchmark (#18850) 2025-06-21 18:29:02 +02:00
ruff_cache Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_db [ty] Add more benchmarks (#18714) 2025-06-18 13:41:38 +02:00
ruff_dev Remove Message::to_rule (#18447) 2025-06-05 12:48:29 -04:00
ruff_diagnostics Add a ViolationMetadata::rule method (#18234) 2025-05-28 09:27:09 -04:00
ruff_formatter Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_graph fix casing of analyze.direction variant names (#18892) 2025-06-23 14:30:30 +02:00
ruff_index Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
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 Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_options_metadata [ty] Document configuration schema (#17950) 2025-05-09 10:47:45 +02:00
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 [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
ruff_python_codegen [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
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 Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_literal Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
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 Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_semantic [flake8-comprehensions] Handle template strings for comprehension fixes (#18710) 2025-06-19 16:23:46 -05:00
ruff_python_stdlib Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_trivia Treat ty: comments as pragma comments (#18532) 2025-06-07 16:02:43 +02:00
ruff_python_trivia_integration_tests Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_server Consider virtual path for various server actions (#18910) 2025-06-24 12:24:28 +00:00
ruff_source_file Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_text_size Add rustfmt.toml file (#18197) 2025-05-19 11:40:58 -04:00
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] Add python.ty.disableLanguageServices config (#18230) 2025-06-17 13:50:45 +05:30
ty_test Remove extra dot in rule documentation (#18871) 2025-06-23 00:33:21 +00:00
ty_vendored Sync vendored typeshed stubs (#18679) 2025-06-15 10:20:33 +01:00
ty_wasm [ty] Add infrastructure for AST garbage collection (#18445) 2025-06-05 11:43:18 -04:00