ruff/crates
Charlie Marsh 20782ab02c
Support type alias statements in simple statement positions (#8916)
<!--
Thank you for contributing to Ruff! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

Our `SoftKeywordTokenizer` only respected soft keywords in compound
statement positions -- for example, at the start of a logical line:

```python
type X = int
```

However, type aliases can also appear in simple statement positions,
like:

```python
class Class: type X = int
```

(Note that `match` and `case` are _not_ valid keywords in such
positions.)

This PR upgrades the tokenizer to track both kinds of valid positions.

Closes https://github.com/astral-sh/ruff/issues/8900.
Closes https://github.com/astral-sh/ruff/issues/8899.

## Test Plan

`cargo test`
2023-11-30 19:15:19 +00:00
..
flake8_to_ruff Bump configparser from 3.0.2 to 3.0.3 (#8849) 2023-11-27 10:07:22 +00:00
ruff_benchmark Add benchmark for running all rules including preview rules (#8865) 2023-11-29 04:26:25 +00:00
ruff_cache Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
ruff_cli Stop at the first resolved parent configuration (#8864) 2023-11-29 04:21:07 +00:00
ruff_dev Update ruff-dev to use SourceKind (#8878) 2023-11-28 14:27:35 -06:00
ruff_diagnostics Update applicability messages for clarity in tests (#8541) 2023-11-07 16:11:43 +00:00
ruff_formatter remove several uses of unsafe (#8600) 2023-11-28 09:50:03 -05:00
ruff_index Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
ruff_linter Use Python version to determine typing rewrite safety (#8919) 2023-11-29 22:22:04 -05:00
ruff_macros remove several uses of unsafe (#8600) 2023-11-28 09:50:03 -05:00
ruff_notebook Update E402 to work at cell level for notebooks (#8872) 2023-11-29 00:32:35 +00:00
ruff_python_ast Enable auto-return-type involving Optional and Union annotations (#8885) 2023-11-28 18:35:55 -08:00
ruff_python_codegen Rename as_str to to_str (#8886) 2023-11-28 18:50:42 -06:00
ruff_python_formatter Update Black tests (#8901) 2023-11-30 00:09:55 +00:00
ruff_python_index Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
ruff_python_literal remove several uses of unsafe (#8600) 2023-11-28 09:50:03 -05:00
ruff_python_parser Support type alias statements in simple statement positions (#8916) 2023-11-30 19:15:19 +00:00
ruff_python_resolver Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
ruff_python_semantic Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
ruff_python_stdlib Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
ruff_python_trivia Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
ruff_shrinking Bump version to v0.1.6 (#8744) 2023-11-17 13:29:19 -05:00
ruff_source_file remove several uses of unsafe (#8600) 2023-11-28 09:50:03 -05:00
ruff_text_size Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
ruff_wasm Bump wasm-bindgen-test from 0.3.37 to 0.3.38 (#8847) 2023-11-27 10:02:53 +00:00
ruff_workspace Stop at the first resolved parent configuration (#8864) 2023-11-29 04:21:07 +00:00