mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:10:09 +00:00
Add typo linter (#1553)
This commit is contained in:
parent
f74050e5b1
commit
e9be5fc7be
12 changed files with 30 additions and 18 deletions
12
.github/workflows/ci.yaml
vendored
12
.github/workflows/ci.yaml
vendored
|
@ -181,3 +181,15 @@ jobs:
|
|||
${{ runner.os }}-build-
|
||||
${{ runner.os }}-
|
||||
- run: maturin build -b bin
|
||||
|
||||
typos:
|
||||
name: Spell Check with Typos
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Actions Repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Check spelling of file.txt
|
||||
uses: crate-ci/typos@master
|
||||
with:
|
||||
files: .
|
||||
|
|
|
@ -376,7 +376,7 @@ class TestGoogle: # noqa: D203
|
|||
Etiam at tellus a tellus faucibus maximus. Curabitur tellus
|
||||
mauris, semper id vehicula ac, feugiat ut tortor.
|
||||
verbose (bool):
|
||||
If True, print out as much infromation as possible.
|
||||
If True, print out as much information as possible.
|
||||
If False, print out concise "one-liner" information.
|
||||
|
||||
"""
|
||||
|
|
|
@ -18,8 +18,8 @@ def isinstances():
|
|||
|
||||
result = isinstance(var[5], int) or True or isinstance(var[5], float) # [consider-merging-isinstance]
|
||||
|
||||
infered_isinstance = isinstance
|
||||
result = infered_isinstance(var[6], int) or infered_isinstance(var[6], float) or infered_isinstance(var[6], list) and False # [consider-merging-isinstance]
|
||||
inferred_isinstance = isinstance
|
||||
result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance]
|
||||
result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list) # [consider-merging-isinstance]
|
||||
result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float) # [consider-merging-isinstance]
|
||||
|
||||
|
|
4
resources/test/fixtures/pyupgrade/UP012.py
vendored
4
resources/test/fixtures/pyupgrade/UP012.py
vendored
|
@ -45,8 +45,8 @@ f"foo{bar}".encode(encoding)
|
|||
"unicode text©".encode()
|
||||
"unicode text©".encode(encoding="UTF8") # "unicode text©".encode()
|
||||
|
||||
r"fo\o".encode("utf-8") # br"fo\o"
|
||||
r"foo\o".encode("utf-8") # br"foo\o"
|
||||
u"foo".encode("utf-8") # b"foo"
|
||||
R"fo\o".encode("utf-8") # br"fo\o"
|
||||
R"foo\o".encode("utf-8") # br"foo\o"
|
||||
U"foo".encode("utf-8") # b"foo"
|
||||
print("foo".encode()) # print(b"foo")
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue