mirror of https://github.com/astral-sh/ruff
Refactor
This commit is contained in:
parent
a780faccd5
commit
13566989b6
|
|
@ -93,10 +93,11 @@ pub fn check_do_not_assign_lambda(value: &Expr, location: Location) -> Option<Ch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_ambiguous_name(name: &str) -> bool {
|
fn is_ambiguous_name(name: &str) -> bool {
|
||||||
name == "l" || name == "I" || name == "O"
|
name == "l" || name == "I" || name == "O"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check AmbiguousVariableName compliance.
|
||||||
pub fn check_ambiguous_variable_name(name: &str, location: Location) -> Option<Check> {
|
pub fn check_ambiguous_variable_name(name: &str, location: Location) -> Option<Check> {
|
||||||
if is_ambiguous_name(name) {
|
if is_ambiguous_name(name) {
|
||||||
Some(Check::new(
|
Some(Check::new(
|
||||||
|
|
|
||||||
|
|
@ -965,11 +965,10 @@ impl<'a> Checker<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.settings.select.contains(&CheckCode::E741) && checks::is_ambiguous_name(id) {
|
if self.settings.select.contains(&CheckCode::E741) {
|
||||||
self.checks.push(Check::new(
|
if let Some(check) = checks::check_ambiguous_variable_name(id, expr.location) {
|
||||||
CheckKind::AmbiguousVariableName(id.to_string()),
|
self.checks.push(check);
|
||||||
expr.location,
|
}
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(charlie): Handle alternate binding types (like `Annotation`).
|
// TODO(charlie): Handle alternate binding types (like `Annotation`).
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue