mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-09 10:00:25 +00:00
![]() ## Summary This PR removes the `debug_assertion` in the `Indexer` to allow unterminated f-strings. This is mainly a fix in the development build which now matches the release build. The fix is simple: remove the `debug_assertion` which means that the there could be `FStringStart` and possibly `FStringMiddle` tokens without a corresponding f-string range in the `Indexer`. This means that the code requesting for the f-string index need to account for the `None` case, making the code safer. This also updates the code which queries the `FStringRanges` to account for the `None` case. This will happen when the `FStringStart` / `FStringMiddle` tokens are present but the `FStringEnd` token isn't which means that the `Indexer` won't contain the range for that f-string. ## Test Plan `cargo test` Taking the following code as an example: ```python f"{123} ``` This only emits a `FStringStart` token, but no `FStringMiddle` or `FStringEnd` tokens. And, ```python f"\.png${ ``` This emits a `FStringStart` and `FStringMiddle` token, but no `FStringEnd` token. fixes: #8065 |
||
---|---|---|
.. | ||
flake8_to_ruff | ||
ruff_benchmark | ||
ruff_cache | ||
ruff_cli | ||
ruff_dev | ||
ruff_diagnostics | ||
ruff_formatter | ||
ruff_index | ||
ruff_linter | ||
ruff_macros | ||
ruff_notebook | ||
ruff_python_ast | ||
ruff_python_codegen | ||
ruff_python_formatter | ||
ruff_python_index | ||
ruff_python_literal | ||
ruff_python_parser | ||
ruff_python_resolver | ||
ruff_python_semantic | ||
ruff_python_stdlib | ||
ruff_python_trivia | ||
ruff_shrinking | ||
ruff_source_file | ||
ruff_text_size | ||
ruff_wasm | ||
ruff_workspace |