mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-17 13:58:37 +00:00
![]() ## 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 |
||
---|---|---|
.. | ||
checkers | ||
comments | ||
cst | ||
docstrings | ||
fix | ||
importer | ||
lex | ||
message | ||
registry | ||
rules | ||
settings | ||
snapshots | ||
codes.rs | ||
directives.rs | ||
doc_lines.rs | ||
fs.rs | ||
lib.rs | ||
line_width.rs | ||
linter.rs | ||
logging.rs | ||
noqa.rs | ||
packaging.rs | ||
pyproject_toml.rs | ||
registry.rs | ||
renamer.rs | ||
rule_redirects.rs | ||
rule_selector.rs | ||
source_kind.rs | ||
test.rs | ||
upstream_categories.rs |