mirror of https://github.com/astral-sh/ruff
[`pyflakes`] Add fix safety section (`F841`) (#17410)
add fix safety section to docs for #15584, I'm new to ruff and not sure if the content of this PR is correct, but I hope it can be helpful. --------- Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>
This commit is contained in:
parent
c36f3f5304
commit
d2ebfd6ed7
|
|
@ -119,7 +119,7 @@ expression: value
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fullDescription": {
|
"fullDescription": {
|
||||||
"text": "## What it does\nChecks for the presence of unused variables in function scopes.\n\n## Why is this bad?\nA variable that is defined but not used is likely a mistake, and should\nbe removed to avoid confusion.\n\nIf a variable is intentionally defined-but-not-used, it should be\nprefixed with an underscore, or some other value that adheres to the\n[`lint.dummy-variable-rgx`] pattern.\n\n## Example\n```python\ndef foo():\n x = 1\n y = 2\n return x\n```\n\nUse instead:\n```python\ndef foo():\n x = 1\n return x\n```\n\n## Options\n- `lint.dummy-variable-rgx`\n"
|
"text": "## What it does\nChecks for the presence of unused variables in function scopes.\n\n## Why is this bad?\nA variable that is defined but not used is likely a mistake, and should\nbe removed to avoid confusion.\n\nIf a variable is intentionally defined-but-not-used, it should be\nprefixed with an underscore, or some other value that adheres to the\n[`lint.dummy-variable-rgx`] pattern.\n\n## Example\n```python\ndef foo():\n x = 1\n y = 2\n return x\n```\n\nUse instead:\n```python\ndef foo():\n x = 1\n return x\n```\n\n## Fix safety\n\nThis rule's fix is marked as unsafe because removing an unused variable assignment may\ndelete comments that are attached to the assignment.\n\n## Options\n- `lint.dummy-variable-rgx`\n"
|
||||||
},
|
},
|
||||||
"help": {
|
"help": {
|
||||||
"text": "Local variable `{name}` is assigned to but never used"
|
"text": "Local variable `{name}` is assigned to but never used"
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,11 @@ use crate::fix::edits::delete_stmt;
|
||||||
/// return x
|
/// return x
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
/// ## Fix safety
|
||||||
|
///
|
||||||
|
/// This rule's fix is marked as unsafe because removing an unused variable assignment may
|
||||||
|
/// delete comments that are attached to the assignment.
|
||||||
|
///
|
||||||
/// ## Options
|
/// ## Options
|
||||||
/// - `lint.dummy-variable-rgx`
|
/// - `lint.dummy-variable-rgx`
|
||||||
#[derive(ViolationMetadata)]
|
#[derive(ViolationMetadata)]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue