mirror of https://github.com/astral-sh/ruff
## Summary In issue https://github.com/astral-sh/ruff/issues/6785 it is reported that a docstring in the form of `''"assert" ' SAM macro definitions '''` is autocorrected to `"""assert" ' SAM macro definitions '''` (note the triple quotes one only one side), which breaks the python program due `undetermined string lateral`. * `Q002`: Not only would docstrings in the form of `''"assert" ' SAM macro definitions '''` (single quotes) be autofixed wrongly, but also e.g. `""'assert' ' SAM macro definitions '''` (double quotes). The bug is present for docstrings in all scopes (e.g. module docstrings, class docstrings, function docstrings) * `Q000`: The autofix error is not only present for `Q002` (docstrings), but also for inline strings (`Q000`). Therefore `s = ''"assert" ' SAM macro definitions '''` will also be wrongly autofixed. Note that situation in which the first string is non-empty can be fixed, e.g. `'123'"assert" ' SAM macro definitions '''` -> `"123""assert" ' SAM macro definitions '''` is valid. ## What * Change FixAvailability of `Q000` `Q002` to `Sometimes` * Changed both rules such that docstrings/inline strings that cannot be fixed are still reported as bad quotes via diagnostics, but no fix is provided ## Test Plan * For `Q000`: Add docstrings in different scopes that (partially) would have been autofixed wrongly * For `Q002`: Add inline strings that (partially) would have been autofixed wrongly Closes https://github.com/astral-sh/ruff/issues/6785 |
||
|---|---|---|
| .. | ||
| ruff | ||
| ruff_benchmark | ||
| ruff_cache | ||
| 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_server | ||
| ruff_shrinking | ||
| ruff_source_file | ||
| ruff_text_size | ||
| ruff_wasm | ||
| ruff_workspace | ||