mirror of
https://github.com/astral-sh/ruff
synced 2026-01-21 21:40:51 -05:00
Add typo linter (#1553)
This commit is contained in:
@@ -3079,7 +3079,7 @@ impl<'a> Checker<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
// If we're about to lose the binding, store it as overriden.
|
||||
// If we're about to lose the binding, store it as overridden.
|
||||
if let Some((scope_index, binding_index)) = overridden {
|
||||
self.scopes[scope_index]
|
||||
.overridden
|
||||
|
||||
@@ -11,7 +11,7 @@ use rustpython_ast::{Stmt, StmtKind};
|
||||
use crate::isort::categorize::{categorize, ImportType};
|
||||
use crate::isort::comments::Comment;
|
||||
use crate::isort::helpers::trailing_comma;
|
||||
use crate::isort::sorting::{cmp_import_froms, cmp_members, cmp_modules};
|
||||
use crate::isort::sorting::{cmp_import_from, cmp_members, cmp_modules};
|
||||
use crate::isort::track::{Block, Trailer};
|
||||
use crate::isort::types::{
|
||||
AliasData, CommentSet, ImportBlock, ImportFromData, Importable, OrderedImportBlock,
|
||||
@@ -483,7 +483,7 @@ fn sort_imports(block: ImportBlock) -> OrderedImportBlock {
|
||||
})
|
||||
.sorted_by(
|
||||
|(import_from1, _, _, aliases1), (import_from2, _, _, aliases2)| {
|
||||
cmp_import_froms(import_from1, import_from2).then_with(|| {
|
||||
cmp_import_from(import_from1, import_from2).then_with(|| {
|
||||
match (aliases1.first(), aliases2.first()) {
|
||||
(None, None) => Ordering::Equal,
|
||||
(None, Some(_)) => Ordering::Less,
|
||||
@@ -650,7 +650,7 @@ mod tests {
|
||||
|
||||
#[test_case(Path::new("add_newline_before_comments.py"))]
|
||||
#[test_case(Path::new("combine_as_imports.py"))]
|
||||
#[test_case(Path::new("combine_import_froms.py"))]
|
||||
#[test_case(Path::new("combine_import_from.py"))]
|
||||
#[test_case(Path::new("comments.py"))]
|
||||
#[test_case(Path::new("deduplicate_imports.py"))]
|
||||
#[test_case(Path::new("fit_line_length.py"))]
|
||||
|
||||
@@ -54,7 +54,7 @@ pub fn cmp_levels(level1: Option<&usize>, level2: Option<&usize>) -> Ordering {
|
||||
}
|
||||
|
||||
/// Compare two `StmtKind::ImportFrom` blocks.
|
||||
pub fn cmp_import_froms(import_from1: &ImportFromData, import_from2: &ImportFromData) -> Ordering {
|
||||
pub fn cmp_import_from(import_from1: &ImportFromData, import_from2: &ImportFromData) -> Ordering {
|
||||
cmp_levels(import_from1.level, import_from2.level).then_with(|| {
|
||||
match (&import_from1.module, import_from2.module) {
|
||||
(None, None) => Ordering::Equal,
|
||||
|
||||
@@ -141,7 +141,7 @@ pub fn remove_unnecessary_future_import(
|
||||
parent: Option<&Stmt>,
|
||||
deleted: &[&Stmt],
|
||||
) -> Result<Fix> {
|
||||
// TODO(charlie): DRY up with pyflakes::fixes::remove_unused_import_froms.
|
||||
// TODO(charlie): DRY up with pyflakes::fixes::remove_unused_import_from.
|
||||
let module_text = locator.slice_source_code_range(&Range::from_located(stmt));
|
||||
let mut tree = match_module(&module_text)?;
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ fn handle_name_or_attribute(
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles one block of an except (use a loop if there are multile blocks)
|
||||
/// Handles one block of an except (use a loop if there are multiple blocks)
|
||||
fn handle_except_block(checker: &mut Checker, handler: &Located<ExcepthandlerKind>) {
|
||||
let ExcepthandlerKind::ExceptHandler { type_, .. } = &handler.node;
|
||||
let Some(error_handlers) = type_.as_ref() else {
|
||||
|
||||
@@ -168,15 +168,15 @@ expression: checks
|
||||
column: 0
|
||||
end_location:
|
||||
row: 48
|
||||
column: 23
|
||||
column: 24
|
||||
fix:
|
||||
content: "br\"fo\\o\""
|
||||
content: "br\"foo\\o\""
|
||||
location:
|
||||
row: 48
|
||||
column: 0
|
||||
end_location:
|
||||
row: 48
|
||||
column: 23
|
||||
column: 24
|
||||
parent: ~
|
||||
- kind: UnnecessaryEncodeUTF8
|
||||
location:
|
||||
@@ -200,15 +200,15 @@ expression: checks
|
||||
column: 0
|
||||
end_location:
|
||||
row: 50
|
||||
column: 23
|
||||
column: 24
|
||||
fix:
|
||||
content: "bR\"fo\\o\""
|
||||
content: "bR\"foo\\o\""
|
||||
location:
|
||||
row: 50
|
||||
column: 0
|
||||
end_location:
|
||||
row: 50
|
||||
column: 23
|
||||
column: 24
|
||||
parent: ~
|
||||
- kind: UnnecessaryEncodeUTF8
|
||||
location:
|
||||
|
||||
Reference in New Issue
Block a user