ruff/crates/ruff_server/src
Brent Westbrook 4510a236d3
Default to latest supported Python version for version-related syntax errors (#17529)
## Summary

This PR partially addresses #16418 via the following:

- `LinterSettings::unresolved_python_version` is now a `TargetVersion`,
which is a thin wrapper around an `Option<PythonVersion>`
- `Checker::target_version` now calls `TargetVersion::linter_version`
internally, which in turn uses `unwrap_or_default` to preserve the
current default behavior
- Calls to the parser now call `TargetVersion::parser_version`, which
calls `unwrap_or_else(PythonVersion::latest)`
- The `Checker`'s implementation of
`SemanticSyntaxContext::python_version` also uses
`TargetVersion::parser_version` to use `PythonVersion::latest` for
semantic errors

In short, all lint rule behavior should be unchanged, but we default to
the latest Python version for the new syntax errors, which should
minimize confusing version-related syntax errors for users without a
version configured.

## Test Plan

Existing tests, which showed no changes (except for printing default
settings).
2025-05-06 10:19:13 -04:00
..
edit Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
server Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
session Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
edit.rs Split SourceLocation into LineColumn and SourceLocation (#17587) 2025-04-27 11:27:33 +01:00
fix.rs Server: Allow FixAll action in presence of version-specific syntax errors (#16848) 2025-03-20 05:09:14 -05:00
format.rs Add per-file-target-version option (#16257) 2025-02-24 08:47:13 -05:00
lib.rs Refactor workspace logic into workspace.rs (#16295) 2025-02-21 08:37:29 +00:00
lint.rs Default to latest supported Python version for version-related syntax errors (#17529) 2025-05-06 10:19:13 -04:00
logging.rs Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
message.rs Fix LSP show message macro to allow format args (#15487) 2025-01-15 08:11:49 +00:00
resolve.rs Root exclusions in the server to project root (#16043) 2025-02-10 04:57:14 +00:00
server.rs Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
session.rs Refactor workspace logic into workspace.rs (#16295) 2025-02-21 08:37:29 +00:00
workspace.rs Refactor workspace logic into workspace.rs (#16295) 2025-02-21 08:37:29 +00:00