mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-21 17:50:14 +00:00
Rename SPR001 to U008 (#379)
This commit is contained in:
parent
6a1d7d8a1c
commit
b51a080a44
6 changed files with 97 additions and 17 deletions
|
@ -287,7 +287,6 @@ The 🛠 emoji indicates that a rule is automatically fixable by the `--fix` com
|
||||||
| C406 | UnnecessaryLiteralDict | Unnecessary <list/tuple> literal - rewrite as a dict literal | | |
|
| C406 | UnnecessaryLiteralDict | Unnecessary <list/tuple> literal - rewrite as a dict literal | | |
|
||||||
| C408 | UnnecessaryCollectionCall | Unnecessary <dict/list/tuple> call - rewrite as a literal | | |
|
| C408 | UnnecessaryCollectionCall | Unnecessary <dict/list/tuple> call - rewrite as a literal | | |
|
||||||
| C415 | UnnecessarySubscriptReversal | Unnecessary subscript reversal of iterable within <reversed/set/sorted>() | | |
|
| C415 | UnnecessarySubscriptReversal | Unnecessary subscript reversal of iterable within <reversed/set/sorted>() | | |
|
||||||
| SPR001 | SuperCallWithParameters | Use `super()` instead of `super(__class__, self)` | | 🛠 |
|
|
||||||
| T201 | PrintFound | `print` found | | 🛠 |
|
| T201 | PrintFound | `print` found | | 🛠 |
|
||||||
| T203 | PPrintFound | `pprint` found | | 🛠 |
|
| T203 | PPrintFound | `pprint` found | | 🛠 |
|
||||||
| U001 | UselessMetaclassType | `__metaclass__ = type` is implied | | 🛠 |
|
| U001 | UselessMetaclassType | `__metaclass__ = type` is implied | | 🛠 |
|
||||||
|
@ -297,6 +296,7 @@ The 🛠 emoji indicates that a rule is automatically fixable by the `--fix` com
|
||||||
| U005 | NoAssertEquals | `assertEquals` is deprecated, use `assertEqual` instead | | 🛠 |
|
| U005 | NoAssertEquals | `assertEquals` is deprecated, use `assertEqual` instead | | 🛠 |
|
||||||
| U006 | UsePEP585Annotation | Use `list` instead of `List` for type annotations | | 🛠 |
|
| U006 | UsePEP585Annotation | Use `list` instead of `List` for type annotations | | 🛠 |
|
||||||
| U007 | UsePEP604Annotation | Use `X \| Y` for type annotations | | 🛠 |
|
| U007 | UsePEP604Annotation | Use `X \| Y` for type annotations | | 🛠 |
|
||||||
|
| U008 | SuperCallWithParameters | Use `super()` instead of `super(__class__, self)` | | 🛠 |
|
||||||
| M001 | UnusedNOQA | Unused `noqa` directive | | 🛠 |
|
| M001 | UnusedNOQA | Unused `noqa` directive | | 🛠 |
|
||||||
|
|
||||||
## Integrations
|
## Integrations
|
||||||
|
|
|
@ -730,7 +730,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
// flake8-super
|
// flake8-super
|
||||||
if self.settings.enabled.contains(&CheckCode::SPR001) {
|
if self.settings.enabled.contains(&CheckCode::U008) {
|
||||||
plugins::super_call_with_parameters(self, expr, func, args);
|
plugins::super_call_with_parameters(self, expr, func, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,8 +130,6 @@ pub enum CheckCode {
|
||||||
C406,
|
C406,
|
||||||
C408,
|
C408,
|
||||||
C415,
|
C415,
|
||||||
// flake8-super
|
|
||||||
SPR001,
|
|
||||||
// flake8-print
|
// flake8-print
|
||||||
T201,
|
T201,
|
||||||
T203,
|
T203,
|
||||||
|
@ -143,6 +141,7 @@ pub enum CheckCode {
|
||||||
U005,
|
U005,
|
||||||
U006,
|
U006,
|
||||||
U007,
|
U007,
|
||||||
|
U008,
|
||||||
// Meta
|
// Meta
|
||||||
M001,
|
M001,
|
||||||
}
|
}
|
||||||
|
@ -221,8 +220,6 @@ pub enum CheckKind {
|
||||||
UnnecessaryLiteralDict(String),
|
UnnecessaryLiteralDict(String),
|
||||||
UnnecessaryCollectionCall(String),
|
UnnecessaryCollectionCall(String),
|
||||||
UnnecessarySubscriptReversal(String),
|
UnnecessarySubscriptReversal(String),
|
||||||
// flake8-super
|
|
||||||
SuperCallWithParameters,
|
|
||||||
// flake8-print
|
// flake8-print
|
||||||
PrintFound,
|
PrintFound,
|
||||||
PPrintFound,
|
PPrintFound,
|
||||||
|
@ -234,6 +231,7 @@ pub enum CheckKind {
|
||||||
UselessObjectInheritance(String),
|
UselessObjectInheritance(String),
|
||||||
UsePEP585Annotation(String),
|
UsePEP585Annotation(String),
|
||||||
UsePEP604Annotation,
|
UsePEP604Annotation,
|
||||||
|
SuperCallWithParameters,
|
||||||
// Meta
|
// Meta
|
||||||
UnusedNOQA(Option<String>),
|
UnusedNOQA(Option<String>),
|
||||||
}
|
}
|
||||||
|
@ -317,8 +315,6 @@ impl CheckCode {
|
||||||
CheckCode::C415 => {
|
CheckCode::C415 => {
|
||||||
CheckKind::UnnecessarySubscriptReversal("<reversed/set/sorted>".to_string())
|
CheckKind::UnnecessarySubscriptReversal("<reversed/set/sorted>".to_string())
|
||||||
}
|
}
|
||||||
// flake8-super
|
|
||||||
CheckCode::SPR001 => CheckKind::SuperCallWithParameters,
|
|
||||||
// flake8-print
|
// flake8-print
|
||||||
CheckCode::T201 => CheckKind::PrintFound,
|
CheckCode::T201 => CheckKind::PrintFound,
|
||||||
CheckCode::T203 => CheckKind::PPrintFound,
|
CheckCode::T203 => CheckKind::PPrintFound,
|
||||||
|
@ -330,6 +326,7 @@ impl CheckCode {
|
||||||
CheckCode::U005 => CheckKind::NoAssertEquals,
|
CheckCode::U005 => CheckKind::NoAssertEquals,
|
||||||
CheckCode::U006 => CheckKind::UsePEP585Annotation("List".to_string()),
|
CheckCode::U006 => CheckKind::UsePEP585Annotation("List".to_string()),
|
||||||
CheckCode::U007 => CheckKind::UsePEP604Annotation,
|
CheckCode::U007 => CheckKind::UsePEP604Annotation,
|
||||||
|
CheckCode::U008 => CheckKind::SuperCallWithParameters,
|
||||||
// Meta
|
// Meta
|
||||||
CheckCode::M001 => CheckKind::UnusedNOQA(None),
|
CheckCode::M001 => CheckKind::UnusedNOQA(None),
|
||||||
}
|
}
|
||||||
|
@ -399,8 +396,6 @@ impl CheckKind {
|
||||||
CheckKind::UnnecessaryLiteralDict(_) => &CheckCode::C406,
|
CheckKind::UnnecessaryLiteralDict(_) => &CheckCode::C406,
|
||||||
CheckKind::UnnecessaryCollectionCall(_) => &CheckCode::C408,
|
CheckKind::UnnecessaryCollectionCall(_) => &CheckCode::C408,
|
||||||
CheckKind::UnnecessarySubscriptReversal(_) => &CheckCode::C415,
|
CheckKind::UnnecessarySubscriptReversal(_) => &CheckCode::C415,
|
||||||
// flake8-super
|
|
||||||
CheckKind::SuperCallWithParameters => &CheckCode::SPR001,
|
|
||||||
// flake8-print
|
// flake8-print
|
||||||
CheckKind::PrintFound => &CheckCode::T201,
|
CheckKind::PrintFound => &CheckCode::T201,
|
||||||
CheckKind::PPrintFound => &CheckCode::T203,
|
CheckKind::PPrintFound => &CheckCode::T203,
|
||||||
|
@ -412,6 +407,7 @@ impl CheckKind {
|
||||||
CheckKind::UsePEP585Annotation(_) => &CheckCode::U006,
|
CheckKind::UsePEP585Annotation(_) => &CheckCode::U006,
|
||||||
CheckKind::UsePEP604Annotation => &CheckCode::U007,
|
CheckKind::UsePEP604Annotation => &CheckCode::U007,
|
||||||
CheckKind::UselessObjectInheritance(_) => &CheckCode::U004,
|
CheckKind::UselessObjectInheritance(_) => &CheckCode::U004,
|
||||||
|
CheckKind::SuperCallWithParameters => &CheckCode::U008,
|
||||||
// Meta
|
// Meta
|
||||||
CheckKind::UnusedNOQA(_) => &CheckCode::M001,
|
CheckKind::UnusedNOQA(_) => &CheckCode::M001,
|
||||||
}
|
}
|
||||||
|
@ -588,10 +584,6 @@ impl CheckKind {
|
||||||
CheckKind::UnnecessarySubscriptReversal(func) => {
|
CheckKind::UnnecessarySubscriptReversal(func) => {
|
||||||
format!("Unnecessary subscript reversal of iterable within {func}()")
|
format!("Unnecessary subscript reversal of iterable within {func}()")
|
||||||
}
|
}
|
||||||
// flake8-super
|
|
||||||
CheckKind::SuperCallWithParameters => {
|
|
||||||
"Use `super()` instead of `super(__class__, self)`".to_string()
|
|
||||||
}
|
|
||||||
// flake8-print
|
// flake8-print
|
||||||
CheckKind::PrintFound => "`print` found".to_string(),
|
CheckKind::PrintFound => "`print` found".to_string(),
|
||||||
CheckKind::PPrintFound => "`pprint` found".to_string(),
|
CheckKind::PPrintFound => "`pprint` found".to_string(),
|
||||||
|
@ -617,6 +609,9 @@ impl CheckKind {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
CheckKind::UsePEP604Annotation => "Use `X | Y` for type annotations".to_string(),
|
CheckKind::UsePEP604Annotation => "Use `X | Y` for type annotations".to_string(),
|
||||||
|
CheckKind::SuperCallWithParameters => {
|
||||||
|
"Use `super()` instead of `super(__class__, self)`".to_string()
|
||||||
|
}
|
||||||
// Meta
|
// Meta
|
||||||
CheckKind::UnusedNOQA(code) => match code {
|
CheckKind::UnusedNOQA(code) => match code {
|
||||||
None => "Unused `noqa` directive".to_string(),
|
None => "Unused `noqa` directive".to_string(),
|
||||||
|
|
|
@ -955,10 +955,10 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn spr001() -> Result<()> {
|
fn u008() -> Result<()> {
|
||||||
let mut checks = check_path(
|
let mut checks = check_path(
|
||||||
Path::new("./resources/test/fixtures/SPR001.py"),
|
Path::new("./resources/test/fixtures/U008.py"),
|
||||||
&settings::Settings::for_rule(CheckCode::SPR001),
|
&settings::Settings::for_rule(CheckCode::U008),
|
||||||
&fixer::Mode::Generate,
|
&fixer::Mode::Generate,
|
||||||
)?;
|
)?;
|
||||||
checks.sort_by_key(|check| check.location);
|
checks.sort_by_key(|check| check.location);
|
||||||
|
|
85
src/snapshots/ruff__linter__tests__u008.snap
Normal file
85
src/snapshots/ruff__linter__tests__u008.snap
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
---
|
||||||
|
source: src/linter.rs
|
||||||
|
expression: checks
|
||||||
|
---
|
||||||
|
- kind: SuperCallWithParameters
|
||||||
|
location:
|
||||||
|
row: 17
|
||||||
|
column: 18
|
||||||
|
end_location:
|
||||||
|
row: 17
|
||||||
|
column: 36
|
||||||
|
fix:
|
||||||
|
content: super()
|
||||||
|
location:
|
||||||
|
row: 17
|
||||||
|
column: 18
|
||||||
|
end_location:
|
||||||
|
row: 17
|
||||||
|
column: 36
|
||||||
|
applied: false
|
||||||
|
- kind: SuperCallWithParameters
|
||||||
|
location:
|
||||||
|
row: 18
|
||||||
|
column: 9
|
||||||
|
end_location:
|
||||||
|
row: 18
|
||||||
|
column: 27
|
||||||
|
fix:
|
||||||
|
content: super()
|
||||||
|
location:
|
||||||
|
row: 18
|
||||||
|
column: 9
|
||||||
|
end_location:
|
||||||
|
row: 18
|
||||||
|
column: 27
|
||||||
|
applied: false
|
||||||
|
- kind: SuperCallWithParameters
|
||||||
|
location:
|
||||||
|
row: 19
|
||||||
|
column: 9
|
||||||
|
end_location:
|
||||||
|
row: 22
|
||||||
|
column: 10
|
||||||
|
fix:
|
||||||
|
content: super()
|
||||||
|
location:
|
||||||
|
row: 19
|
||||||
|
column: 9
|
||||||
|
end_location:
|
||||||
|
row: 22
|
||||||
|
column: 10
|
||||||
|
applied: false
|
||||||
|
- kind: SuperCallWithParameters
|
||||||
|
location:
|
||||||
|
row: 36
|
||||||
|
column: 9
|
||||||
|
end_location:
|
||||||
|
row: 36
|
||||||
|
column: 29
|
||||||
|
fix:
|
||||||
|
content: super()
|
||||||
|
location:
|
||||||
|
row: 36
|
||||||
|
column: 9
|
||||||
|
end_location:
|
||||||
|
row: 36
|
||||||
|
column: 29
|
||||||
|
applied: false
|
||||||
|
- kind: SuperCallWithParameters
|
||||||
|
location:
|
||||||
|
row: 50
|
||||||
|
column: 13
|
||||||
|
end_location:
|
||||||
|
row: 50
|
||||||
|
column: 33
|
||||||
|
fix:
|
||||||
|
content: super()
|
||||||
|
location:
|
||||||
|
row: 50
|
||||||
|
column: 13
|
||||||
|
end_location:
|
||||||
|
row: 50
|
||||||
|
column: 33
|
||||||
|
applied: false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue