mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 05:15:12 +00:00
[Ruff v0.5] Stabilise 15 pylint rules (#12051)
This commit is contained in:
parent
0917ce16f4
commit
4029a25ebd
14 changed files with 95 additions and 84 deletions
|
@ -191,14 +191,14 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
|
||||||
(Pylint, "C0414") => (RuleGroup::Stable, rules::pylint::rules::UselessImportAlias),
|
(Pylint, "C0414") => (RuleGroup::Stable, rules::pylint::rules::UselessImportAlias),
|
||||||
(Pylint, "C0415") => (RuleGroup::Preview, rules::pylint::rules::ImportOutsideTopLevel),
|
(Pylint, "C0415") => (RuleGroup::Preview, rules::pylint::rules::ImportOutsideTopLevel),
|
||||||
(Pylint, "C1901") => (RuleGroup::Preview, rules::pylint::rules::CompareToEmptyString),
|
(Pylint, "C1901") => (RuleGroup::Preview, rules::pylint::rules::CompareToEmptyString),
|
||||||
(Pylint, "C2401") => (RuleGroup::Preview, rules::pylint::rules::NonAsciiName),
|
(Pylint, "C2401") => (RuleGroup::Stable, rules::pylint::rules::NonAsciiName),
|
||||||
(Pylint, "C2403") => (RuleGroup::Preview, rules::pylint::rules::NonAsciiImportName),
|
(Pylint, "C2403") => (RuleGroup::Stable, rules::pylint::rules::NonAsciiImportName),
|
||||||
(Pylint, "C2701") => (RuleGroup::Preview, rules::pylint::rules::ImportPrivateName),
|
(Pylint, "C2701") => (RuleGroup::Preview, rules::pylint::rules::ImportPrivateName),
|
||||||
(Pylint, "C2801") => (RuleGroup::Preview, rules::pylint::rules::UnnecessaryDunderCall),
|
(Pylint, "C2801") => (RuleGroup::Preview, rules::pylint::rules::UnnecessaryDunderCall),
|
||||||
(Pylint, "C3002") => (RuleGroup::Stable, rules::pylint::rules::UnnecessaryDirectLambdaCall),
|
(Pylint, "C3002") => (RuleGroup::Stable, rules::pylint::rules::UnnecessaryDirectLambdaCall),
|
||||||
(Pylint, "E0100") => (RuleGroup::Stable, rules::pylint::rules::YieldInInit),
|
(Pylint, "E0100") => (RuleGroup::Stable, rules::pylint::rules::YieldInInit),
|
||||||
(Pylint, "E0101") => (RuleGroup::Stable, rules::pylint::rules::ReturnInInit),
|
(Pylint, "E0101") => (RuleGroup::Stable, rules::pylint::rules::ReturnInInit),
|
||||||
(Pylint, "E0115") => (RuleGroup::Preview, rules::pylint::rules::NonlocalAndGlobal),
|
(Pylint, "E0115") => (RuleGroup::Stable, rules::pylint::rules::NonlocalAndGlobal),
|
||||||
(Pylint, "E0116") => (RuleGroup::Stable, rules::pylint::rules::ContinueInFinally),
|
(Pylint, "E0116") => (RuleGroup::Stable, rules::pylint::rules::ContinueInFinally),
|
||||||
(Pylint, "E0117") => (RuleGroup::Stable, rules::pylint::rules::NonlocalWithoutBinding),
|
(Pylint, "E0117") => (RuleGroup::Stable, rules::pylint::rules::NonlocalWithoutBinding),
|
||||||
(Pylint, "E0118") => (RuleGroup::Stable, rules::pylint::rules::LoadBeforeGlobalDeclaration),
|
(Pylint, "E0118") => (RuleGroup::Stable, rules::pylint::rules::LoadBeforeGlobalDeclaration),
|
||||||
|
@ -213,9 +213,9 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
|
||||||
(Pylint, "E0309") => (RuleGroup::Preview, rules::pylint::rules::InvalidHashReturnType),
|
(Pylint, "E0309") => (RuleGroup::Preview, rules::pylint::rules::InvalidHashReturnType),
|
||||||
(Pylint, "E0604") => (RuleGroup::Stable, rules::pylint::rules::InvalidAllObject),
|
(Pylint, "E0604") => (RuleGroup::Stable, rules::pylint::rules::InvalidAllObject),
|
||||||
(Pylint, "E0605") => (RuleGroup::Stable, rules::pylint::rules::InvalidAllFormat),
|
(Pylint, "E0605") => (RuleGroup::Stable, rules::pylint::rules::InvalidAllFormat),
|
||||||
(Pylint, "E0643") => (RuleGroup::Preview, rules::pylint::rules::PotentialIndexError),
|
(Pylint, "E0643") => (RuleGroup::Stable, rules::pylint::rules::PotentialIndexError),
|
||||||
(Pylint, "E0704") => (RuleGroup::Preview, rules::pylint::rules::MisplacedBareRaise),
|
(Pylint, "E0704") => (RuleGroup::Stable, rules::pylint::rules::MisplacedBareRaise),
|
||||||
(Pylint, "E1132") => (RuleGroup::Preview, rules::pylint::rules::RepeatedKeywordArgument),
|
(Pylint, "E1132") => (RuleGroup::Stable, rules::pylint::rules::RepeatedKeywordArgument),
|
||||||
(Pylint, "E1141") => (RuleGroup::Preview, rules::pylint::rules::DictIterMissingItems),
|
(Pylint, "E1141") => (RuleGroup::Preview, rules::pylint::rules::DictIterMissingItems),
|
||||||
(Pylint, "E1142") => (RuleGroup::Stable, rules::pylint::rules::AwaitOutsideAsync),
|
(Pylint, "E1142") => (RuleGroup::Stable, rules::pylint::rules::AwaitOutsideAsync),
|
||||||
(Pylint, "E1205") => (RuleGroup::Stable, rules::pylint::rules::LoggingTooManyArgs),
|
(Pylint, "E1205") => (RuleGroup::Stable, rules::pylint::rules::LoggingTooManyArgs),
|
||||||
|
@ -250,16 +250,16 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
|
||||||
(Pylint, "R0917") => (RuleGroup::Preview, rules::pylint::rules::TooManyPositional),
|
(Pylint, "R0917") => (RuleGroup::Preview, rules::pylint::rules::TooManyPositional),
|
||||||
(Pylint, "R1701") => (RuleGroup::Removed, rules::pylint::rules::RepeatedIsinstanceCalls),
|
(Pylint, "R1701") => (RuleGroup::Removed, rules::pylint::rules::RepeatedIsinstanceCalls),
|
||||||
(Pylint, "R1702") => (RuleGroup::Preview, rules::pylint::rules::TooManyNestedBlocks),
|
(Pylint, "R1702") => (RuleGroup::Preview, rules::pylint::rules::TooManyNestedBlocks),
|
||||||
(Pylint, "R1704") => (RuleGroup::Preview, rules::pylint::rules::RedefinedArgumentFromLocal),
|
(Pylint, "R1704") => (RuleGroup::Stable, rules::pylint::rules::RedefinedArgumentFromLocal),
|
||||||
(Pylint, "R1706") => (RuleGroup::Removed, rules::pylint::rules::AndOrTernary),
|
(Pylint, "R1706") => (RuleGroup::Removed, rules::pylint::rules::AndOrTernary),
|
||||||
(Pylint, "R1711") => (RuleGroup::Stable, rules::pylint::rules::UselessReturn),
|
(Pylint, "R1711") => (RuleGroup::Stable, rules::pylint::rules::UselessReturn),
|
||||||
(Pylint, "R1714") => (RuleGroup::Stable, rules::pylint::rules::RepeatedEqualityComparison),
|
(Pylint, "R1714") => (RuleGroup::Stable, rules::pylint::rules::RepeatedEqualityComparison),
|
||||||
(Pylint, "R1722") => (RuleGroup::Stable, rules::pylint::rules::SysExitAlias),
|
(Pylint, "R1722") => (RuleGroup::Stable, rules::pylint::rules::SysExitAlias),
|
||||||
(Pylint, "R1730") => (RuleGroup::Preview, rules::pylint::rules::IfStmtMinMax),
|
(Pylint, "R1730") => (RuleGroup::Preview, rules::pylint::rules::IfStmtMinMax),
|
||||||
(Pylint, "R1733") => (RuleGroup::Preview, rules::pylint::rules::UnnecessaryDictIndexLookup),
|
(Pylint, "R1733") => (RuleGroup::Preview, rules::pylint::rules::UnnecessaryDictIndexLookup),
|
||||||
(Pylint, "R1736") => (RuleGroup::Preview, rules::pylint::rules::UnnecessaryListIndexLookup),
|
(Pylint, "R1736") => (RuleGroup::Stable, rules::pylint::rules::UnnecessaryListIndexLookup),
|
||||||
(Pylint, "R2004") => (RuleGroup::Stable, rules::pylint::rules::MagicValueComparison),
|
(Pylint, "R2004") => (RuleGroup::Stable, rules::pylint::rules::MagicValueComparison),
|
||||||
(Pylint, "R2044") => (RuleGroup::Preview, rules::pylint::rules::EmptyComment),
|
(Pylint, "R2044") => (RuleGroup::Stable, rules::pylint::rules::EmptyComment),
|
||||||
(Pylint, "R5501") => (RuleGroup::Stable, rules::pylint::rules::CollapsibleElseIf),
|
(Pylint, "R5501") => (RuleGroup::Stable, rules::pylint::rules::CollapsibleElseIf),
|
||||||
(Pylint, "R6104") => (RuleGroup::Preview, rules::pylint::rules::NonAugmentedAssignment),
|
(Pylint, "R6104") => (RuleGroup::Preview, rules::pylint::rules::NonAugmentedAssignment),
|
||||||
(Pylint, "R6201") => (RuleGroup::Preview, rules::pylint::rules::LiteralMembership),
|
(Pylint, "R6201") => (RuleGroup::Preview, rules::pylint::rules::LiteralMembership),
|
||||||
|
@ -268,25 +268,25 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
|
||||||
(Pylint, "W0177") => (RuleGroup::Preview, rules::pylint::rules::NanComparison),
|
(Pylint, "W0177") => (RuleGroup::Preview, rules::pylint::rules::NanComparison),
|
||||||
(Pylint, "W0120") => (RuleGroup::Stable, rules::pylint::rules::UselessElseOnLoop),
|
(Pylint, "W0120") => (RuleGroup::Stable, rules::pylint::rules::UselessElseOnLoop),
|
||||||
(Pylint, "W0127") => (RuleGroup::Stable, rules::pylint::rules::SelfAssigningVariable),
|
(Pylint, "W0127") => (RuleGroup::Stable, rules::pylint::rules::SelfAssigningVariable),
|
||||||
(Pylint, "W0128") => (RuleGroup::Preview, rules::pylint::rules::RedeclaredAssignedName),
|
(Pylint, "W0128") => (RuleGroup::Stable, rules::pylint::rules::RedeclaredAssignedName),
|
||||||
(Pylint, "W0129") => (RuleGroup::Stable, rules::pylint::rules::AssertOnStringLiteral),
|
(Pylint, "W0129") => (RuleGroup::Stable, rules::pylint::rules::AssertOnStringLiteral),
|
||||||
(Pylint, "W0131") => (RuleGroup::Stable, rules::pylint::rules::NamedExprWithoutContext),
|
(Pylint, "W0131") => (RuleGroup::Stable, rules::pylint::rules::NamedExprWithoutContext),
|
||||||
(Pylint, "W0133") => (RuleGroup::Preview, rules::pylint::rules::UselessExceptionStatement),
|
(Pylint, "W0133") => (RuleGroup::Stable, rules::pylint::rules::UselessExceptionStatement),
|
||||||
(Pylint, "W0211") => (RuleGroup::Preview, rules::pylint::rules::BadStaticmethodArgument),
|
(Pylint, "W0211") => (RuleGroup::Preview, rules::pylint::rules::BadStaticmethodArgument),
|
||||||
(Pylint, "W0245") => (RuleGroup::Preview, rules::pylint::rules::SuperWithoutBrackets),
|
(Pylint, "W0245") => (RuleGroup::Stable, rules::pylint::rules::SuperWithoutBrackets),
|
||||||
(Pylint, "W0406") => (RuleGroup::Stable, rules::pylint::rules::ImportSelf),
|
(Pylint, "W0406") => (RuleGroup::Stable, rules::pylint::rules::ImportSelf),
|
||||||
(Pylint, "W0602") => (RuleGroup::Stable, rules::pylint::rules::GlobalVariableNotAssigned),
|
(Pylint, "W0602") => (RuleGroup::Stable, rules::pylint::rules::GlobalVariableNotAssigned),
|
||||||
(Pylint, "W0603") => (RuleGroup::Stable, rules::pylint::rules::GlobalStatement),
|
(Pylint, "W0603") => (RuleGroup::Stable, rules::pylint::rules::GlobalStatement),
|
||||||
(Pylint, "W0604") => (RuleGroup::Preview, rules::pylint::rules::GlobalAtModuleLevel),
|
(Pylint, "W0604") => (RuleGroup::Stable, rules::pylint::rules::GlobalAtModuleLevel),
|
||||||
(Pylint, "W0642") => (RuleGroup::Preview, rules::pylint::rules::SelfOrClsAssignment),
|
(Pylint, "W0642") => (RuleGroup::Preview, rules::pylint::rules::SelfOrClsAssignment),
|
||||||
(Pylint, "W0711") => (RuleGroup::Stable, rules::pylint::rules::BinaryOpException),
|
(Pylint, "W0711") => (RuleGroup::Stable, rules::pylint::rules::BinaryOpException),
|
||||||
(Pylint, "W1501") => (RuleGroup::Preview, rules::pylint::rules::BadOpenMode),
|
(Pylint, "W1501") => (RuleGroup::Stable, rules::pylint::rules::BadOpenMode),
|
||||||
(Pylint, "W1508") => (RuleGroup::Stable, rules::pylint::rules::InvalidEnvvarDefault),
|
(Pylint, "W1508") => (RuleGroup::Stable, rules::pylint::rules::InvalidEnvvarDefault),
|
||||||
(Pylint, "W1509") => (RuleGroup::Stable, rules::pylint::rules::SubprocessPopenPreexecFn),
|
(Pylint, "W1509") => (RuleGroup::Stable, rules::pylint::rules::SubprocessPopenPreexecFn),
|
||||||
(Pylint, "W1510") => (RuleGroup::Stable, rules::pylint::rules::SubprocessRunWithoutCheck),
|
(Pylint, "W1510") => (RuleGroup::Stable, rules::pylint::rules::SubprocessRunWithoutCheck),
|
||||||
(Pylint, "W1514") => (RuleGroup::Preview, rules::pylint::rules::UnspecifiedEncoding),
|
(Pylint, "W1514") => (RuleGroup::Preview, rules::pylint::rules::UnspecifiedEncoding),
|
||||||
(Pylint, "W1641") => (RuleGroup::Preview, rules::pylint::rules::EqWithoutHash),
|
(Pylint, "W1641") => (RuleGroup::Preview, rules::pylint::rules::EqWithoutHash),
|
||||||
(Pylint, "W2101") => (RuleGroup::Preview, rules::pylint::rules::UselessWithLock),
|
(Pylint, "W2101") => (RuleGroup::Stable, rules::pylint::rules::UselessWithLock),
|
||||||
(Pylint, "W2901") => (RuleGroup::Stable, rules::pylint::rules::RedefinedLoopName),
|
(Pylint, "W2901") => (RuleGroup::Stable, rules::pylint::rules::RedefinedLoopName),
|
||||||
(Pylint, "W3201") => (RuleGroup::Preview, rules::pylint::rules::BadDunderMethodName),
|
(Pylint, "W3201") => (RuleGroup::Preview, rules::pylint::rules::BadDunderMethodName),
|
||||||
(Pylint, "W3301") => (RuleGroup::Stable, rules::pylint::rules::NestedMinMax),
|
(Pylint, "W3301") => (RuleGroup::Stable, rules::pylint::rules::NestedMinMax),
|
||||||
|
|
|
@ -59,7 +59,7 @@ pub(crate) fn bad_open_mode(checker: &mut Checker, call: &ast::ExprCall) {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Some(ast::ExprStringLiteral { value, .. }) = mode.as_string_literal_expr() else {
|
let ast::Expr::StringLiteral(ast::ExprStringLiteral { value, .. }) = mode else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ pub struct LiteralMembership;
|
||||||
impl AlwaysFixableViolation for LiteralMembership {
|
impl AlwaysFixableViolation for LiteralMembership {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
fn message(&self) -> String {
|
fn message(&self) -> String {
|
||||||
format!("Use a `set` literal when testing for membership")
|
format!("Use a set literal when testing for membership")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fix_title(&self) -> String {
|
fn fix_title(&self) -> String {
|
||||||
|
|
|
@ -41,20 +41,20 @@ impl Violation for NonAsciiImportName {
|
||||||
let Self { name, kind } = self;
|
let Self { name, kind } = self;
|
||||||
match kind {
|
match kind {
|
||||||
Kind::Aliased => {
|
Kind::Aliased => {
|
||||||
format!(
|
format!("Module alias `{name}` contains a non-ASCII character")
|
||||||
"Module alias `{name}` contains a non-ASCII character, use an ASCII-only alias"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Kind::Unaliased => {
|
Kind::Unaliased => {
|
||||||
format!(
|
format!("Module name `{name}` contains a non-ASCII character")
|
||||||
"Module name `{name}` contains a non-ASCII character, use an ASCII-only alias"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn fix_title(&self) -> Option<String> {
|
||||||
|
Some("Use an ASCII-only alias".to_string())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
enum Kind {
|
enum Kind {
|
||||||
/// The import uses a non-ASCII alias (e.g., `import foo as bár`).
|
/// The import uses a non-ASCII alias (e.g., `import foo as bár`).
|
||||||
Aliased,
|
Aliased,
|
||||||
|
|
|
@ -34,7 +34,11 @@ impl Violation for NonAsciiName {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
fn message(&self) -> String {
|
fn message(&self) -> String {
|
||||||
let Self { name, kind } = self;
|
let Self { name, kind } = self;
|
||||||
format!("{kind} name `{name}` contains a non-ASCII character, consider renaming it")
|
format!("{kind} name `{name}` contains a non-ASCII character")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fix_title(&self) -> Option<String> {
|
||||||
|
Some("Rename the variable using ASCII characters".to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +86,7 @@ pub(crate) fn non_ascii_name(binding: &Binding, locator: &Locator) -> Option<Dia
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
||||||
enum Kind {
|
enum Kind {
|
||||||
Annotation,
|
Annotation,
|
||||||
Argument,
|
Argument,
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub struct PotentialIndexError;
|
||||||
impl Violation for PotentialIndexError {
|
impl Violation for PotentialIndexError {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
fn message(&self) -> String {
|
fn message(&self) -> String {
|
||||||
format!("Potential IndexError")
|
format!("Expression is likely to raise `IndexError`")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,14 @@ use ruff_text_size::Ranged;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
||||||
/// ## What it does
|
/// ## What it does
|
||||||
/// Checks for `super` calls without parentheses.
|
/// Detects attempts to use `super` without parentheses.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// When `super` is used without parentheses, it is not an actual call, and
|
/// The [`super()` callable](https://docs.python.org/3/library/functions.html#super)
|
||||||
/// thus has no effect.
|
/// can be used inside method definitions to create a proxy object that
|
||||||
|
/// delegates attribute access to a superclass of the current class. Attempting
|
||||||
|
/// to access attributes on `super` itself, however, instead of the object
|
||||||
|
/// returned by a call to `super()`, will raise `AttributeError`.
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```python
|
/// ```python
|
||||||
|
@ -25,7 +28,7 @@ use crate::checkers::ast::Checker;
|
||||||
/// class Dog(Animal):
|
/// class Dog(Animal):
|
||||||
/// @staticmethod
|
/// @staticmethod
|
||||||
/// def speak():
|
/// def speak():
|
||||||
/// original_speak = super.speak()
|
/// original_speak = super.speak() # ERROR: `super.speak()`
|
||||||
/// return f"{original_speak} But as a dog, it barks!"
|
/// return f"{original_speak} But as a dog, it barks!"
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
@ -40,7 +43,7 @@ use crate::checkers::ast::Checker;
|
||||||
/// class Dog(Animal):
|
/// class Dog(Animal):
|
||||||
/// @staticmethod
|
/// @staticmethod
|
||||||
/// def speak():
|
/// def speak():
|
||||||
/// original_speak = super().speak()
|
/// original_speak = super().speak() # Correct: `super().speak()`
|
||||||
/// return f"{original_speak} But as a dog, it barks!"
|
/// return f"{original_speak} But as a dog, it barks!"
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[violation]
|
||||||
|
|
|
@ -37,11 +37,11 @@ pub struct UnnecessaryListIndexLookup;
|
||||||
impl AlwaysFixableViolation for UnnecessaryListIndexLookup {
|
impl AlwaysFixableViolation for UnnecessaryListIndexLookup {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
fn message(&self) -> String {
|
fn message(&self) -> String {
|
||||||
format!("Unnecessary lookup of list item by index")
|
format!("List index lookup in `enumerate()` loop")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fix_title(&self) -> String {
|
fn fix_title(&self) -> String {
|
||||||
format!("Use existing variable")
|
format!("Use the loop variable directly")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@ use ruff_text_size::Ranged;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
||||||
/// ## What it does
|
/// ## What it does
|
||||||
/// Checks for direct uses of lock objects in `with` statements.
|
/// Checks for lock objects that are created and immediately discarded in
|
||||||
|
/// `with` statements.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// Creating a lock (via `threading.Lock` or similar) in a `with` statement
|
/// Creating a lock (via `threading.Lock` or similar) in a `with` statement
|
||||||
|
|
|
@ -1,23 +1,25 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff_linter/src/rules/pylint/mod.rs
|
source: crates/ruff_linter/src/rules/pylint/mod.rs
|
||||||
---
|
---
|
||||||
non_ascii_name.py:1:1: PLC2401 Variable name `ápple_count` contains a non-ASCII character, consider renaming it
|
non_ascii_name.py:1:1: PLC2401 Variable name `ápple_count` contains a non-ASCII character
|
||||||
|
|
|
|
||||||
1 | ápple_count: int = 1 # C2401
|
1 | ápple_count: int = 1 # C2401
|
||||||
| ^^^^^^^^^^^ PLC2401
|
| ^^^^^^^^^^^ PLC2401
|
||||||
2 | ápple_count += 2 # C2401
|
2 | ápple_count += 2 # C2401
|
||||||
3 | ápple_count = 3 # C2401
|
3 | ápple_count = 3 # C2401
|
||||||
|
|
|
|
||||||
|
= help: Rename the variable using ASCII characters
|
||||||
|
|
||||||
non_ascii_name.py:2:1: PLC2401 Variable name `ápple_count` contains a non-ASCII character, consider renaming it
|
non_ascii_name.py:2:1: PLC2401 Variable name `ápple_count` contains a non-ASCII character
|
||||||
|
|
|
|
||||||
1 | ápple_count: int = 1 # C2401
|
1 | ápple_count: int = 1 # C2401
|
||||||
2 | ápple_count += 2 # C2401
|
2 | ápple_count += 2 # C2401
|
||||||
| ^^^^^^^^^^^ PLC2401
|
| ^^^^^^^^^^^ PLC2401
|
||||||
3 | ápple_count = 3 # C2401
|
3 | ápple_count = 3 # C2401
|
||||||
|
|
|
|
||||||
|
= help: Rename the variable using ASCII characters
|
||||||
|
|
||||||
non_ascii_name.py:3:1: PLC2401 Variable name `ápple_count` contains a non-ASCII character, consider renaming it
|
non_ascii_name.py:3:1: PLC2401 Variable name `ápple_count` contains a non-ASCII character
|
||||||
|
|
|
|
||||||
1 | ápple_count: int = 1 # C2401
|
1 | ápple_count: int = 1 # C2401
|
||||||
2 | ápple_count += 2 # C2401
|
2 | ápple_count += 2 # C2401
|
||||||
|
@ -26,47 +28,53 @@ non_ascii_name.py:3:1: PLC2401 Variable name `ápple_count` contains a non-ASCII
|
||||||
4 |
|
4 |
|
||||||
5 | (ápple_count for ápple_count in y)
|
5 | (ápple_count for ápple_count in y)
|
||||||
|
|
|
|
||||||
|
= help: Rename the variable using ASCII characters
|
||||||
|
|
||||||
non_ascii_name.py:5:18: PLC2401 Variable name `ápple_count` contains a non-ASCII character, consider renaming it
|
non_ascii_name.py:5:18: PLC2401 Variable name `ápple_count` contains a non-ASCII character
|
||||||
|
|
|
|
||||||
3 | ápple_count = 3 # C2401
|
3 | ápple_count = 3 # C2401
|
||||||
4 |
|
4 |
|
||||||
5 | (ápple_count for ápple_count in y)
|
5 | (ápple_count for ápple_count in y)
|
||||||
| ^^^^^^^^^^^ PLC2401
|
| ^^^^^^^^^^^ PLC2401
|
||||||
|
|
|
|
||||||
|
= help: Rename the variable using ASCII characters
|
||||||
|
|
||||||
non_ascii_name.py:8:10: PLC2401 Argument name `ápple_count` contains a non-ASCII character, consider renaming it
|
non_ascii_name.py:8:10: PLC2401 Argument name `ápple_count` contains a non-ASCII character
|
||||||
|
|
|
|
||||||
8 | def func(ápple_count):
|
8 | def func(ápple_count):
|
||||||
| ^^^^^^^^^^^ PLC2401
|
| ^^^^^^^^^^^ PLC2401
|
||||||
9 | global ápple_count
|
9 | global ápple_count
|
||||||
10 | nonlocal ápple_count
|
10 | nonlocal ápple_count
|
||||||
|
|
|
|
||||||
|
= help: Rename the variable using ASCII characters
|
||||||
|
|
||||||
non_ascii_name.py:9:12: PLC2401 Global name `ápple_count` contains a non-ASCII character, consider renaming it
|
non_ascii_name.py:9:12: PLC2401 Global name `ápple_count` contains a non-ASCII character
|
||||||
|
|
|
|
||||||
8 | def func(ápple_count):
|
8 | def func(ápple_count):
|
||||||
9 | global ápple_count
|
9 | global ápple_count
|
||||||
| ^^^^^^^^^^^ PLC2401
|
| ^^^^^^^^^^^ PLC2401
|
||||||
10 | nonlocal ápple_count
|
10 | nonlocal ápple_count
|
||||||
|
|
|
|
||||||
|
= help: Rename the variable using ASCII characters
|
||||||
|
|
||||||
non_ascii_name.py:13:5: PLC2401 Function name `ápple_count` contains a non-ASCII character, consider renaming it
|
non_ascii_name.py:13:5: PLC2401 Function name `ápple_count` contains a non-ASCII character
|
||||||
|
|
|
|
||||||
13 | def ápple_count():
|
13 | def ápple_count():
|
||||||
| ^^^^^^^^^^^ PLC2401
|
| ^^^^^^^^^^^ PLC2401
|
||||||
14 | pass
|
14 | pass
|
||||||
|
|
|
|
||||||
|
= help: Rename the variable using ASCII characters
|
||||||
|
|
||||||
non_ascii_name.py:18:10: PLC2401 Variable name `ápple_count` contains a non-ASCII character, consider renaming it
|
non_ascii_name.py:18:10: PLC2401 Variable name `ápple_count` contains a non-ASCII character
|
||||||
|
|
|
|
||||||
17 | match ápple_count:
|
17 | match ápple_count:
|
||||||
18 | case ápple_count:
|
18 | case ápple_count:
|
||||||
| ^^^^^^^^^^^ PLC2401
|
| ^^^^^^^^^^^ PLC2401
|
||||||
19 | pass
|
19 | pass
|
||||||
|
|
|
|
||||||
|
= help: Rename the variable using ASCII characters
|
||||||
|
|
||||||
non_ascii_name.py:21:1: PLC2401 Annotation name `ápple_count` contains a non-ASCII character, consider renaming it
|
non_ascii_name.py:21:1: PLC2401 Annotation name `ápple_count` contains a non-ASCII character
|
||||||
|
|
|
|
||||||
19 | pass
|
19 | pass
|
||||||
20 |
|
20 |
|
||||||
|
@ -75,5 +83,4 @@ non_ascii_name.py:21:1: PLC2401 Annotation name `ápple_count` contains a non-AS
|
||||||
22 |
|
22 |
|
||||||
23 | try:
|
23 | try:
|
||||||
|
|
|
|
||||||
|
= help: Rename the variable using ASCII characters
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff_linter/src/rules/pylint/mod.rs
|
source: crates/ruff_linter/src/rules/pylint/mod.rs
|
||||||
---
|
---
|
||||||
non_ascii_module_import.py:1:29: PLC2403 Module alias `łos` contains a non-ASCII character, use an ASCII-only alias
|
non_ascii_module_import.py:1:29: PLC2403 Module alias `łos` contains a non-ASCII character
|
||||||
|
|
|
|
||||||
1 | from os.path import join as łos # Error
|
1 | from os.path import join as łos # Error
|
||||||
| ^^^ PLC2403
|
| ^^^ PLC2403
|
||||||
2 | from os.path import join as los # OK
|
2 | from os.path import join as los # OK
|
||||||
|
|
|
|
||||||
|
= help: Use an ASCII-only alias
|
||||||
|
|
||||||
non_ascii_module_import.py:4:24: PLC2403 Module alias `łos` contains a non-ASCII character, use an ASCII-only alias
|
non_ascii_module_import.py:4:24: PLC2403 Module alias `łos` contains a non-ASCII character
|
||||||
|
|
|
|
||||||
2 | from os.path import join as los # OK
|
2 | from os.path import join as los # OK
|
||||||
3 |
|
3 |
|
||||||
|
@ -16,8 +17,9 @@ non_ascii_module_import.py:4:24: PLC2403 Module alias `łos` contains a non-ASCI
|
||||||
| ^^^ PLC2403
|
| ^^^ PLC2403
|
||||||
5 | import os.path.join as los # OK
|
5 | import os.path.join as los # OK
|
||||||
|
|
|
|
||||||
|
= help: Use an ASCII-only alias
|
||||||
|
|
||||||
non_ascii_module_import.py:7:8: PLC2403 Module name `os.path.łos` contains a non-ASCII character, use an ASCII-only alias
|
non_ascii_module_import.py:7:8: PLC2403 Module name `os.path.łos` contains a non-ASCII character
|
||||||
|
|
|
|
||||||
5 | import os.path.join as los # OK
|
5 | import os.path.join as los # OK
|
||||||
6 |
|
6 |
|
||||||
|
@ -25,8 +27,9 @@ non_ascii_module_import.py:7:8: PLC2403 Module name `os.path.łos` contains a no
|
||||||
| ^^^^^^^^^^^ PLC2403
|
| ^^^^^^^^^^^ PLC2403
|
||||||
8 | import os.path.los # OK
|
8 | import os.path.los # OK
|
||||||
|
|
|
|
||||||
|
= help: Use an ASCII-only alias
|
||||||
|
|
||||||
non_ascii_module_import.py:10:21: PLC2403 Module name `łos` contains a non-ASCII character, use an ASCII-only alias
|
non_ascii_module_import.py:10:21: PLC2403 Module name `łos` contains a non-ASCII character
|
||||||
|
|
|
|
||||||
8 | import os.path.los # OK
|
8 | import os.path.los # OK
|
||||||
9 |
|
9 |
|
||||||
|
@ -34,5 +37,4 @@ non_ascii_module_import.py:10:21: PLC2403 Module name `łos` contains a non-ASCI
|
||||||
| ^^^ PLC2403
|
| ^^^ PLC2403
|
||||||
11 | from os.path import los # OK
|
11 | from os.path import los # OK
|
||||||
|
|
|
|
||||||
|
= help: Use an ASCII-only alias
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff_linter/src/rules/pylint/mod.rs
|
source: crates/ruff_linter/src/rules/pylint/mod.rs
|
||||||
---
|
---
|
||||||
potential_index_error.py:1:17: PLE0643 Potential IndexError
|
potential_index_error.py:1:17: PLE0643 Expression is likely to raise `IndexError`
|
||||||
|
|
|
|
||||||
1 | print([1, 2, 3][3]) # PLE0643
|
1 | print([1, 2, 3][3]) # PLE0643
|
||||||
| ^ PLE0643
|
| ^ PLE0643
|
||||||
|
@ -9,7 +9,7 @@ potential_index_error.py:1:17: PLE0643 Potential IndexError
|
||||||
3 | print([1, 2, 3][999999999999999999999999999999999999999999]) # PLE0643
|
3 | print([1, 2, 3][999999999999999999999999999999999999999999]) # PLE0643
|
||||||
|
|
|
|
||||||
|
|
||||||
potential_index_error.py:2:17: PLE0643 Potential IndexError
|
potential_index_error.py:2:17: PLE0643 Expression is likely to raise `IndexError`
|
||||||
|
|
|
|
||||||
1 | print([1, 2, 3][3]) # PLE0643
|
1 | print([1, 2, 3][3]) # PLE0643
|
||||||
2 | print([1, 2, 3][-4]) # PLE0643
|
2 | print([1, 2, 3][-4]) # PLE0643
|
||||||
|
@ -18,7 +18,7 @@ potential_index_error.py:2:17: PLE0643 Potential IndexError
|
||||||
4 | print([1, 2, 3][-999999999999999999999999999999999999999999]) # PLE0643
|
4 | print([1, 2, 3][-999999999999999999999999999999999999999999]) # PLE0643
|
||||||
|
|
|
|
||||||
|
|
||||||
potential_index_error.py:3:17: PLE0643 Potential IndexError
|
potential_index_error.py:3:17: PLE0643 Expression is likely to raise `IndexError`
|
||||||
|
|
|
|
||||||
1 | print([1, 2, 3][3]) # PLE0643
|
1 | print([1, 2, 3][3]) # PLE0643
|
||||||
2 | print([1, 2, 3][-4]) # PLE0643
|
2 | print([1, 2, 3][-4]) # PLE0643
|
||||||
|
@ -27,7 +27,7 @@ potential_index_error.py:3:17: PLE0643 Potential IndexError
|
||||||
4 | print([1, 2, 3][-999999999999999999999999999999999999999999]) # PLE0643
|
4 | print([1, 2, 3][-999999999999999999999999999999999999999999]) # PLE0643
|
||||||
|
|
|
|
||||||
|
|
||||||
potential_index_error.py:4:17: PLE0643 Potential IndexError
|
potential_index_error.py:4:17: PLE0643 Expression is likely to raise `IndexError`
|
||||||
|
|
|
|
||||||
2 | print([1, 2, 3][-4]) # PLE0643
|
2 | print([1, 2, 3][-4]) # PLE0643
|
||||||
3 | print([1, 2, 3][999999999999999999999999999999999999999999]) # PLE0643
|
3 | print([1, 2, 3][999999999999999999999999999999999999999999]) # PLE0643
|
||||||
|
@ -36,5 +36,3 @@ potential_index_error.py:4:17: PLE0643 Potential IndexError
|
||||||
5 |
|
5 |
|
||||||
6 | print([1, 2, 3][2]) # OK
|
6 | print([1, 2, 3][2]) # OK
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff_linter/src/rules/pylint/mod.rs
|
source: crates/ruff_linter/src/rules/pylint/mod.rs
|
||||||
---
|
---
|
||||||
unnecessary_list_index_lookup.py:7:6: PLR1736 [*] Unnecessary lookup of list item by index
|
unnecessary_list_index_lookup.py:7:6: PLR1736 [*] List index lookup in `enumerate()` loop
|
||||||
|
|
|
|
||||||
6 | def fix_these():
|
6 | def fix_these():
|
||||||
7 | [letters[index] for index, letter in enumerate(letters)] # PLR1736
|
7 | [letters[index] for index, letter in enumerate(letters)] # PLR1736
|
||||||
|
@ -9,7 +9,7 @@ unnecessary_list_index_lookup.py:7:6: PLR1736 [*] Unnecessary lookup of list ite
|
||||||
8 | {letters[index] for index, letter in enumerate(letters)} # PLR1736
|
8 | {letters[index] for index, letter in enumerate(letters)} # PLR1736
|
||||||
9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736
|
9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736
|
||||||
|
|
|
|
||||||
= help: Use existing variable
|
= help: Use the loop variable directly
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
4 4 |
|
4 4 |
|
||||||
|
@ -21,7 +21,7 @@ unnecessary_list_index_lookup.py:7:6: PLR1736 [*] Unnecessary lookup of list ite
|
||||||
9 9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736
|
9 9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736
|
||||||
10 10 |
|
10 10 |
|
||||||
|
|
||||||
unnecessary_list_index_lookup.py:8:6: PLR1736 [*] Unnecessary lookup of list item by index
|
unnecessary_list_index_lookup.py:8:6: PLR1736 [*] List index lookup in `enumerate()` loop
|
||||||
|
|
|
|
||||||
6 | def fix_these():
|
6 | def fix_these():
|
||||||
7 | [letters[index] for index, letter in enumerate(letters)] # PLR1736
|
7 | [letters[index] for index, letter in enumerate(letters)] # PLR1736
|
||||||
|
@ -29,7 +29,7 @@ unnecessary_list_index_lookup.py:8:6: PLR1736 [*] Unnecessary lookup of list ite
|
||||||
| ^^^^^^^^^^^^^^ PLR1736
|
| ^^^^^^^^^^^^^^ PLR1736
|
||||||
9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736
|
9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736
|
||||||
|
|
|
|
||||||
= help: Use existing variable
|
= help: Use the loop variable directly
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
5 5 |
|
5 5 |
|
||||||
|
@ -41,7 +41,7 @@ unnecessary_list_index_lookup.py:8:6: PLR1736 [*] Unnecessary lookup of list ite
|
||||||
10 10 |
|
10 10 |
|
||||||
11 11 | for index, letter in enumerate(letters):
|
11 11 | for index, letter in enumerate(letters):
|
||||||
|
|
||||||
unnecessary_list_index_lookup.py:9:14: PLR1736 [*] Unnecessary lookup of list item by index
|
unnecessary_list_index_lookup.py:9:14: PLR1736 [*] List index lookup in `enumerate()` loop
|
||||||
|
|
|
|
||||||
7 | [letters[index] for index, letter in enumerate(letters)] # PLR1736
|
7 | [letters[index] for index, letter in enumerate(letters)] # PLR1736
|
||||||
8 | {letters[index] for index, letter in enumerate(letters)} # PLR1736
|
8 | {letters[index] for index, letter in enumerate(letters)} # PLR1736
|
||||||
|
@ -50,7 +50,7 @@ unnecessary_list_index_lookup.py:9:14: PLR1736 [*] Unnecessary lookup of list it
|
||||||
10 |
|
10 |
|
||||||
11 | for index, letter in enumerate(letters):
|
11 | for index, letter in enumerate(letters):
|
||||||
|
|
|
|
||||||
= help: Use existing variable
|
= help: Use the loop variable directly
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
6 6 | def fix_these():
|
6 6 | def fix_these():
|
||||||
|
@ -62,7 +62,7 @@ unnecessary_list_index_lookup.py:9:14: PLR1736 [*] Unnecessary lookup of list it
|
||||||
11 11 | for index, letter in enumerate(letters):
|
11 11 | for index, letter in enumerate(letters):
|
||||||
12 12 | print(letters[index]) # PLR1736
|
12 12 | print(letters[index]) # PLR1736
|
||||||
|
|
||||||
unnecessary_list_index_lookup.py:12:15: PLR1736 [*] Unnecessary lookup of list item by index
|
unnecessary_list_index_lookup.py:12:15: PLR1736 [*] List index lookup in `enumerate()` loop
|
||||||
|
|
|
|
||||||
11 | for index, letter in enumerate(letters):
|
11 | for index, letter in enumerate(letters):
|
||||||
12 | print(letters[index]) # PLR1736
|
12 | print(letters[index]) # PLR1736
|
||||||
|
@ -70,7 +70,7 @@ unnecessary_list_index_lookup.py:12:15: PLR1736 [*] Unnecessary lookup of list i
|
||||||
13 | blah = letters[index] # PLR1736
|
13 | blah = letters[index] # PLR1736
|
||||||
14 | assert letters[index] == "d" # PLR1736
|
14 | assert letters[index] == "d" # PLR1736
|
||||||
|
|
|
|
||||||
= help: Use existing variable
|
= help: Use the loop variable directly
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
9 9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736
|
9 9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736
|
||||||
|
@ -82,7 +82,7 @@ unnecessary_list_index_lookup.py:12:15: PLR1736 [*] Unnecessary lookup of list i
|
||||||
14 14 | assert letters[index] == "d" # PLR1736
|
14 14 | assert letters[index] == "d" # PLR1736
|
||||||
15 15 |
|
15 15 |
|
||||||
|
|
||||||
unnecessary_list_index_lookup.py:13:16: PLR1736 [*] Unnecessary lookup of list item by index
|
unnecessary_list_index_lookup.py:13:16: PLR1736 [*] List index lookup in `enumerate()` loop
|
||||||
|
|
|
|
||||||
11 | for index, letter in enumerate(letters):
|
11 | for index, letter in enumerate(letters):
|
||||||
12 | print(letters[index]) # PLR1736
|
12 | print(letters[index]) # PLR1736
|
||||||
|
@ -90,7 +90,7 @@ unnecessary_list_index_lookup.py:13:16: PLR1736 [*] Unnecessary lookup of list i
|
||||||
| ^^^^^^^^^^^^^^ PLR1736
|
| ^^^^^^^^^^^^^^ PLR1736
|
||||||
14 | assert letters[index] == "d" # PLR1736
|
14 | assert letters[index] == "d" # PLR1736
|
||||||
|
|
|
|
||||||
= help: Use existing variable
|
= help: Use the loop variable directly
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
10 10 |
|
10 10 |
|
||||||
|
@ -102,7 +102,7 @@ unnecessary_list_index_lookup.py:13:16: PLR1736 [*] Unnecessary lookup of list i
|
||||||
15 15 |
|
15 15 |
|
||||||
16 16 | for index, letter in builtins.enumerate(letters):
|
16 16 | for index, letter in builtins.enumerate(letters):
|
||||||
|
|
||||||
unnecessary_list_index_lookup.py:14:16: PLR1736 [*] Unnecessary lookup of list item by index
|
unnecessary_list_index_lookup.py:14:16: PLR1736 [*] List index lookup in `enumerate()` loop
|
||||||
|
|
|
|
||||||
12 | print(letters[index]) # PLR1736
|
12 | print(letters[index]) # PLR1736
|
||||||
13 | blah = letters[index] # PLR1736
|
13 | blah = letters[index] # PLR1736
|
||||||
|
@ -111,7 +111,7 @@ unnecessary_list_index_lookup.py:14:16: PLR1736 [*] Unnecessary lookup of list i
|
||||||
15 |
|
15 |
|
||||||
16 | for index, letter in builtins.enumerate(letters):
|
16 | for index, letter in builtins.enumerate(letters):
|
||||||
|
|
|
|
||||||
= help: Use existing variable
|
= help: Use the loop variable directly
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
11 11 | for index, letter in enumerate(letters):
|
11 11 | for index, letter in enumerate(letters):
|
||||||
|
@ -123,7 +123,7 @@ unnecessary_list_index_lookup.py:14:16: PLR1736 [*] Unnecessary lookup of list i
|
||||||
16 16 | for index, letter in builtins.enumerate(letters):
|
16 16 | for index, letter in builtins.enumerate(letters):
|
||||||
17 17 | print(letters[index]) # PLR1736
|
17 17 | print(letters[index]) # PLR1736
|
||||||
|
|
||||||
unnecessary_list_index_lookup.py:17:15: PLR1736 [*] Unnecessary lookup of list item by index
|
unnecessary_list_index_lookup.py:17:15: PLR1736 [*] List index lookup in `enumerate()` loop
|
||||||
|
|
|
|
||||||
16 | for index, letter in builtins.enumerate(letters):
|
16 | for index, letter in builtins.enumerate(letters):
|
||||||
17 | print(letters[index]) # PLR1736
|
17 | print(letters[index]) # PLR1736
|
||||||
|
@ -131,7 +131,7 @@ unnecessary_list_index_lookup.py:17:15: PLR1736 [*] Unnecessary lookup of list i
|
||||||
18 | blah = letters[index] # PLR1736
|
18 | blah = letters[index] # PLR1736
|
||||||
19 | assert letters[index] == "d" # PLR1736
|
19 | assert letters[index] == "d" # PLR1736
|
||||||
|
|
|
|
||||||
= help: Use existing variable
|
= help: Use the loop variable directly
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
14 14 | assert letters[index] == "d" # PLR1736
|
14 14 | assert letters[index] == "d" # PLR1736
|
||||||
|
@ -143,7 +143,7 @@ unnecessary_list_index_lookup.py:17:15: PLR1736 [*] Unnecessary lookup of list i
|
||||||
19 19 | assert letters[index] == "d" # PLR1736
|
19 19 | assert letters[index] == "d" # PLR1736
|
||||||
20 20 |
|
20 20 |
|
||||||
|
|
||||||
unnecessary_list_index_lookup.py:18:16: PLR1736 [*] Unnecessary lookup of list item by index
|
unnecessary_list_index_lookup.py:18:16: PLR1736 [*] List index lookup in `enumerate()` loop
|
||||||
|
|
|
|
||||||
16 | for index, letter in builtins.enumerate(letters):
|
16 | for index, letter in builtins.enumerate(letters):
|
||||||
17 | print(letters[index]) # PLR1736
|
17 | print(letters[index]) # PLR1736
|
||||||
|
@ -151,7 +151,7 @@ unnecessary_list_index_lookup.py:18:16: PLR1736 [*] Unnecessary lookup of list i
|
||||||
| ^^^^^^^^^^^^^^ PLR1736
|
| ^^^^^^^^^^^^^^ PLR1736
|
||||||
19 | assert letters[index] == "d" # PLR1736
|
19 | assert letters[index] == "d" # PLR1736
|
||||||
|
|
|
|
||||||
= help: Use existing variable
|
= help: Use the loop variable directly
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
15 15 |
|
15 15 |
|
||||||
|
@ -163,14 +163,14 @@ unnecessary_list_index_lookup.py:18:16: PLR1736 [*] Unnecessary lookup of list i
|
||||||
20 20 |
|
20 20 |
|
||||||
21 21 |
|
21 21 |
|
||||||
|
|
||||||
unnecessary_list_index_lookup.py:19:16: PLR1736 [*] Unnecessary lookup of list item by index
|
unnecessary_list_index_lookup.py:19:16: PLR1736 [*] List index lookup in `enumerate()` loop
|
||||||
|
|
|
|
||||||
17 | print(letters[index]) # PLR1736
|
17 | print(letters[index]) # PLR1736
|
||||||
18 | blah = letters[index] # PLR1736
|
18 | blah = letters[index] # PLR1736
|
||||||
19 | assert letters[index] == "d" # PLR1736
|
19 | assert letters[index] == "d" # PLR1736
|
||||||
| ^^^^^^^^^^^^^^ PLR1736
|
| ^^^^^^^^^^^^^^ PLR1736
|
||||||
|
|
|
|
||||||
= help: Use existing variable
|
= help: Use the loop variable directly
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
16 16 | for index, letter in builtins.enumerate(letters):
|
16 16 | for index, letter in builtins.enumerate(letters):
|
||||||
|
@ -181,5 +181,3 @@ unnecessary_list_index_lookup.py:19:16: PLR1736 [*] Unnecessary lookup of list i
|
||||||
20 20 |
|
20 20 |
|
||||||
21 21 |
|
21 21 |
|
||||||
22 22 | def dont_fix_these():
|
22 22 | def dont_fix_these():
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff_linter/src/rules/pylint/mod.rs
|
source: crates/ruff_linter/src/rules/pylint/mod.rs
|
||||||
---
|
---
|
||||||
literal_membership.py:2:6: PLR6201 [*] Use a `set` literal when testing for membership
|
literal_membership.py:2:6: PLR6201 [*] Use a set literal when testing for membership
|
||||||
|
|
|
|
||||||
1 | # Errors
|
1 | # Errors
|
||||||
2 | 1 in [1, 2, 3]
|
2 | 1 in [1, 2, 3]
|
||||||
|
@ -19,7 +19,7 @@ literal_membership.py:2:6: PLR6201 [*] Use a `set` literal when testing for memb
|
||||||
4 4 | 1 in (
|
4 4 | 1 in (
|
||||||
5 5 | 1, 2, 3
|
5 5 | 1, 2, 3
|
||||||
|
|
||||||
literal_membership.py:3:6: PLR6201 [*] Use a `set` literal when testing for membership
|
literal_membership.py:3:6: PLR6201 [*] Use a set literal when testing for membership
|
||||||
|
|
|
|
||||||
1 | # Errors
|
1 | # Errors
|
||||||
2 | 1 in [1, 2, 3]
|
2 | 1 in [1, 2, 3]
|
||||||
|
@ -39,7 +39,7 @@ literal_membership.py:3:6: PLR6201 [*] Use a `set` literal when testing for memb
|
||||||
5 5 | 1, 2, 3
|
5 5 | 1, 2, 3
|
||||||
6 6 | )
|
6 6 | )
|
||||||
|
|
||||||
literal_membership.py:4:6: PLR6201 [*] Use a `set` literal when testing for membership
|
literal_membership.py:4:6: PLR6201 [*] Use a set literal when testing for membership
|
||||||
|
|
|
|
||||||
2 | 1 in [1, 2, 3]
|
2 | 1 in [1, 2, 3]
|
||||||
3 | 1 in (1, 2, 3)
|
3 | 1 in (1, 2, 3)
|
||||||
|
@ -66,7 +66,7 @@ literal_membership.py:4:6: PLR6201 [*] Use a `set` literal when testing for memb
|
||||||
8 8 | "cherry" in fruits
|
8 8 | "cherry" in fruits
|
||||||
9 9 | _ = {key: value for key, value in {"a": 1, "b": 2}.items() if key in ("a", "b")}
|
9 9 | _ = {key: value for key, value in {"a": 1, "b": 2}.items() if key in ("a", "b")}
|
||||||
|
|
||||||
literal_membership.py:9:70: PLR6201 [*] Use a `set` literal when testing for membership
|
literal_membership.py:9:70: PLR6201 [*] Use a set literal when testing for membership
|
||||||
|
|
|
|
||||||
7 | fruits = ["cherry", "grapes"]
|
7 | fruits = ["cherry", "grapes"]
|
||||||
8 | "cherry" in fruits
|
8 | "cherry" in fruits
|
||||||
|
@ -86,5 +86,3 @@ literal_membership.py:9:70: PLR6201 [*] Use a `set` literal when testing for mem
|
||||||
10 10 |
|
10 10 |
|
||||||
11 11 | # OK
|
11 11 | # OK
|
||||||
12 12 | fruits in [[1, 2, 3], [4, 5, 6]]
|
12 12 | fruits in [[1, 2, 3], [4, 5, 6]]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue