ruff/crates/red_knot_python_semantic/resources/mdtest/diagnostics
Brent Westbrook 9c47b6dbb0
[red-knot] Detect version-related syntax errors (#16379)
## Summary
This PR extends version-related syntax error detection to red-knot. The
main changes here are:

1. Passing `ParseOptions` specifying a `PythonVersion` to parser calls
2. Adding a `python_version` method to the `Db` trait to make this
possible
3. Converting `UnsupportedSyntaxError`s to `Diagnostic`s
4. Updating existing mdtests  to avoid unrelated syntax errors

My initial draft of (1) and (2) in #16090 instead tried passing a
`PythonVersion` down to every parser call, but @MichaReiser suggested
the `Db` approach instead
[here](https://github.com/astral-sh/ruff/pull/16090#discussion_r1969198407),
and I think it turned out much nicer.

All of the new `python_version` methods look like this:

```rust
fn python_version(&self) -> ruff_python_ast::PythonVersion {
    Program::get(self).python_version(self)
}
```

with the exception of the `TestDb` in `ruff_db`, which hard-codes
`PythonVersion::latest()`.

## Test Plan

Existing mdtests, plus a new mdtest to see at least one of the new
diagnostics.
2025-04-17 14:00:30 -04:00
..
attribute_assignment.md [red-knot] Document current state of attribute assignment diagnostics (#16746) 2025-03-14 20:34:43 +01:00
invalid_argument_type.md [red-knot] Better diagnostics for method calls (#16362) 2025-02-25 09:58:08 +01:00
no_matching_overload.md [red-knot] Support multiple overloads when binding parameters at call sites (#16568) 2025-03-11 15:08:17 -04:00
unpacking.md [red-knot] Fix diagnostic range for non-iterable unpacking assignments (#15994) 2025-02-06 15:36:22 +01:00
unresolved_import.md [red-knot] fix unresolvable import range (#15976) 2025-02-05 14:01:58 -05:00
version_related_syntax_errors.md [red-knot] Detect version-related syntax errors (#16379) 2025-04-17 14:00:30 -04:00