Allow passing ParseOptions to inline tests (#16357)

## Summary

This PR adds support for a pragma-style header for inline parser tests
containing JSON-serialized `ParseOptions`. For example,

```python
# parse_options: { "target-version": "3.9" }
match 2:
    case 1:
        pass
```

The line must start with `# parse_options: ` and then the rest of the
(trimmed) line is deserialized into `ParseOptions` used for parsing the
the test.

## Test Plan

Existing inline tests, plus two new inline tests for
`match-before-py310`.

---------

Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
This commit is contained in:
Brent Westbrook
2025-02-27 10:23:15 -05:00
committed by GitHub
parent 568cf88c6c
commit 764aa0e6a1
8 changed files with 238 additions and 7 deletions

View File

@@ -29,10 +29,13 @@ unicode-normalization = { workspace = true }
[dev-dependencies]
ruff_annotate_snippets = { workspace = true }
ruff_python_ast = { workspace = true, features = ["serde"] }
ruff_source_file = { workspace = true }
anyhow = { workspace = true }
insta = { workspace = true, features = ["glob"] }
serde = { workspace = true }
serde_json = { workspace = true }
walkdir = { workspace = true }
[lints]