Compare commits

...

7 Commits

Author SHA1 Message Date
Charlie Marsh
a3cd3dd802 Move last-mile check filtering to linter.rs 2022-11-07 22:05:37 -05:00
Charlie Marsh
7c3d387abd Implement confusing unicode character detection for comments (#653) 2022-11-07 21:16:34 -05:00
Charlie Marsh
d600650214 Upgrade RustPython (#652) 2022-11-07 21:07:49 -05:00
Charlie Marsh
43383bb696 Bump version to 0.0.107 2022-11-07 16:39:03 -05:00
Charlie Marsh
ff83f356af Fix failing flake8-to-ruff tests 2022-11-07 16:38:46 -05:00
Anders Kaseorg
89622425d4 Run annotations plugin if ANN204, ANN205, ANN206 are selected (#649) 2022-11-07 16:37:49 -05:00
Charlie Marsh
1aafe31c00 Avoid U009 violations when disabled (#650) 2022-11-07 16:36:39 -05:00
32 changed files with 348 additions and 358 deletions

View File

@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.106
rev: v0.0.107
hooks:
- id: ruff

14
Cargo.lock generated
View File

@@ -920,7 +920,7 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
[[package]]
name = "flake8-to-ruff"
version = "0.0.106-dev.0"
version = "0.0.107-dev.0"
dependencies = [
"anyhow",
"clap 4.0.15",
@@ -2221,7 +2221,7 @@ dependencies = [
[[package]]
name = "ruff"
version = "0.0.106"
version = "0.0.107"
dependencies = [
"anyhow",
"assert_cmd",
@@ -2266,7 +2266,7 @@ dependencies = [
[[package]]
name = "ruff_dev"
version = "0.0.106"
version = "0.0.107"
dependencies = [
"anyhow",
"clap 4.0.15",
@@ -2295,7 +2295,7 @@ dependencies = [
[[package]]
name = "rustpython-ast"
version = "0.1.0"
source = "git+https://github.com/RustPython/RustPython.git?rev=77b821a1941019fe34f73ce17cea013ae1b98fd0#77b821a1941019fe34f73ce17cea013ae1b98fd0"
source = "git+https://github.com/RustPython/RustPython.git?rev=27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb#27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb"
dependencies = [
"num-bigint",
"rustpython-common",
@@ -2305,7 +2305,7 @@ dependencies = [
[[package]]
name = "rustpython-common"
version = "0.0.0"
source = "git+https://github.com/RustPython/RustPython.git?rev=77b821a1941019fe34f73ce17cea013ae1b98fd0#77b821a1941019fe34f73ce17cea013ae1b98fd0"
source = "git+https://github.com/RustPython/RustPython.git?rev=27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb#27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb"
dependencies = [
"ascii",
"cfg-if 1.0.0",
@@ -2328,7 +2328,7 @@ dependencies = [
[[package]]
name = "rustpython-compiler-core"
version = "0.1.2"
source = "git+https://github.com/RustPython/RustPython.git?rev=77b821a1941019fe34f73ce17cea013ae1b98fd0#77b821a1941019fe34f73ce17cea013ae1b98fd0"
source = "git+https://github.com/RustPython/RustPython.git?rev=27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb#27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb"
dependencies = [
"bincode",
"bitflags",
@@ -2345,7 +2345,7 @@ dependencies = [
[[package]]
name = "rustpython-parser"
version = "0.1.2"
source = "git+https://github.com/RustPython/RustPython.git?rev=77b821a1941019fe34f73ce17cea013ae1b98fd0#77b821a1941019fe34f73ce17cea013ae1b98fd0"
source = "git+https://github.com/RustPython/RustPython.git?rev=27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb#27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb"
dependencies = [
"ahash",
"anyhow",

View File

@@ -6,7 +6,7 @@ members = [
[package]
name = "ruff"
version = "0.0.106"
version = "0.0.107"
edition = "2021"
[lib]
@@ -33,9 +33,9 @@ path-absolutize = { version = "3.0.14", features = ["once_cell_cache", "use_unix
rayon = { version = "1.5.3" }
regex = { version = "1.6.0" }
ropey = { version = "1.5.0" }
rustpython-ast = { features = ["unparse"], git = "https://github.com/RustPython/RustPython.git", rev = "77b821a1941019fe34f73ce17cea013ae1b98fd0" }
rustpython-common = { git = "https://github.com/RustPython/RustPython.git", rev = "77b821a1941019fe34f73ce17cea013ae1b98fd0" }
rustpython-parser = { features = ["lalrpop"], git = "https://github.com/RustPython/RustPython.git", rev = "77b821a1941019fe34f73ce17cea013ae1b98fd0" }
rustpython-ast = { features = ["unparse"], git = "https://github.com/RustPython/RustPython.git", rev = "27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb" }
rustpython-common = { git = "https://github.com/RustPython/RustPython.git", rev = "27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb" }
rustpython-parser = { features = ["lalrpop"], git = "https://github.com/RustPython/RustPython.git", rev = "27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb" }
serde = { version = "1.0.143", features = ["derive"] }
serde_json = { version = "1.0.83" }
strum = { version = "0.24.1", features = ["strum_macros"] }

View File

@@ -97,7 +97,7 @@ Ruff also works with [pre-commit](https://pre-commit.com):
```yaml
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.106
rev: v0.0.107
hooks:
- id: ruff
```
@@ -552,6 +552,7 @@ For more, see [flake8-annotations](https://pypi.org/project/flake8-annotations/2
| ---- | ---- | ------- | --- |
| RUF001 | AmbiguousUnicodeCharacterString | String contains ambiguous unicode character '𝐁' (did you mean 'B'?) | 🛠 |
| RUF002 | AmbiguousUnicodeCharacterDocstring | Docstring contains ambiguous unicode character '𝐁' (did you mean 'B'?) | 🛠 |
| RUF003 | AmbiguousUnicodeCharacterComment | Comment contains ambiguous unicode character '𝐁' (did you mean 'B'?) | |
### Meta rules

View File

@@ -771,7 +771,7 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
[[package]]
name = "flake8_to_ruff"
version = "0.0.106"
version = "0.0.107"
dependencies = [
"anyhow",
"clap",
@@ -1975,7 +1975,7 @@ dependencies = [
[[package]]
name = "ruff"
version = "0.0.106"
version = "0.0.107"
dependencies = [
"anyhow",
"bincode",
@@ -2028,7 +2028,7 @@ dependencies = [
[[package]]
name = "rustpython-ast"
version = "0.1.0"
source = "git+https://github.com/RustPython/RustPython.git?rev=77b821a1941019fe34f73ce17cea013ae1b98fd0#77b821a1941019fe34f73ce17cea013ae1b98fd0"
source = "git+https://github.com/RustPython/RustPython.git?rev=27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb#27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb"
dependencies = [
"num-bigint",
"rustpython-common",
@@ -2038,7 +2038,7 @@ dependencies = [
[[package]]
name = "rustpython-common"
version = "0.0.0"
source = "git+https://github.com/RustPython/RustPython.git?rev=77b821a1941019fe34f73ce17cea013ae1b98fd0#77b821a1941019fe34f73ce17cea013ae1b98fd0"
source = "git+https://github.com/RustPython/RustPython.git?rev=27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb#27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb"
dependencies = [
"ascii",
"cfg-if 1.0.0",
@@ -2061,7 +2061,7 @@ dependencies = [
[[package]]
name = "rustpython-compiler-core"
version = "0.1.2"
source = "git+https://github.com/RustPython/RustPython.git?rev=77b821a1941019fe34f73ce17cea013ae1b98fd0#77b821a1941019fe34f73ce17cea013ae1b98fd0"
source = "git+https://github.com/RustPython/RustPython.git?rev=27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb#27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb"
dependencies = [
"bincode",
"bitflags",
@@ -2078,7 +2078,7 @@ dependencies = [
[[package]]
name = "rustpython-parser"
version = "0.1.2"
source = "git+https://github.com/RustPython/RustPython.git?rev=77b821a1941019fe34f73ce17cea013ae1b98fd0#77b821a1941019fe34f73ce17cea013ae1b98fd0"
source = "git+https://github.com/RustPython/RustPython.git?rev=27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb#27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb"
dependencies = [
"ahash",
"anyhow",

View File

@@ -1,6 +1,6 @@
[package]
name = "flake8-to-ruff"
version = "0.0.106-dev.0"
version = "0.0.107-dev.0"
edition = "2021"
[lib]

View File

@@ -202,6 +202,7 @@ mod tests {
let actual = convert(&HashMap::from([]), None)?;
let expected = Pyproject::new(Options {
line_length: None,
fix: None,
exclude: None,
extend_exclude: None,
select: Some(vec![
@@ -232,6 +233,7 @@ mod tests {
)?;
let expected = Pyproject::new(Options {
line_length: Some(100),
fix: None,
exclude: None,
extend_exclude: None,
select: Some(vec![
@@ -262,6 +264,7 @@ mod tests {
)?;
let expected = Pyproject::new(Options {
line_length: Some(100),
fix: None,
exclude: None,
extend_exclude: None,
select: Some(vec![
@@ -292,6 +295,7 @@ mod tests {
)?;
let expected = Pyproject::new(Options {
line_length: None,
fix: None,
exclude: None,
extend_exclude: None,
select: Some(vec![
@@ -322,6 +326,7 @@ mod tests {
)?;
let expected = Pyproject::new(Options {
line_length: None,
fix: None,
exclude: None,
extend_exclude: None,
select: Some(vec![
@@ -360,6 +365,7 @@ mod tests {
)?;
let expected = Pyproject::new(Options {
line_length: None,
fix: None,
exclude: None,
extend_exclude: None,
select: Some(vec![
@@ -425,6 +431,7 @@ mod tests {
)?;
let expected = Pyproject::new(Options {
line_length: None,
fix: None,
exclude: None,
extend_exclude: None,
select: Some(vec![

View File

@@ -2,5 +2,6 @@ x = "𝐁ad string"
def f():
"""Here's a comment with an unusual parenthesis: """
"""Here's a docstring with an unusual parenthesis: """
# And here's a comment with an unusual punctuation mark:
...

View File

@@ -2,5 +2,6 @@ x = "𝐁ad string"
def f():
"""Here's a comment with an unusual parenthesis: """
"""Here's a docstring with an unusual parenthesis: """
# And here's a comment with an unusual punctuation mark:
...

7
resources/test/fixtures/RUF003.py vendored Normal file
View File

@@ -0,0 +1,7 @@
x = "𝐁ad string"
def f():
"""Here's a docstring with an unusual parenthesis: """
# And here's a comment with an unusual punctuation mark:
...

View File

@@ -1,6 +1,6 @@
[package]
name = "ruff_dev"
version = "0.0.106"
version = "0.0.107"
edition = "2021"
[dependencies]
@@ -9,8 +9,8 @@ clap = { version = "4.0.1", features = ["derive"] }
codegen = { version = "0.2.0" }
itertools = { version = "0.10.5" }
ruff = { path = ".." }
rustpython-ast = { features = ["unparse"], git = "https://github.com/RustPython/RustPython.git", rev = "77b821a1941019fe34f73ce17cea013ae1b98fd0" }
rustpython-common = { git = "https://github.com/RustPython/RustPython.git", rev = "77b821a1941019fe34f73ce17cea013ae1b98fd0" }
rustpython-parser = { features = ["lalrpop"], git = "https://github.com/RustPython/RustPython.git", rev = "77b821a1941019fe34f73ce17cea013ae1b98fd0" }
rustpython-ast = { features = ["unparse"], git = "https://github.com/RustPython/RustPython.git", rev = "27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb" }
rustpython-common = { git = "https://github.com/RustPython/RustPython.git", rev = "27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb" }
rustpython-parser = { features = ["lalrpop"], git = "https://github.com/RustPython/RustPython.git", rev = "27bf82a2251d7e6ac6cd75e6ad51be12a53d84bb" }
strum = { version = "0.24.1", features = ["strum_macros"] }
strum_macros = { version = "0.24.3" }

View File

@@ -970,17 +970,14 @@ where
}
ExprKind::Tuple { elts, ctx } | ExprKind::List { elts, ctx } => {
if matches!(ctx, ExprContext::Store) {
let check_too_many_expressions =
self.settings.enabled.contains(&CheckCode::F621);
let check_two_starred_expressions =
self.settings.enabled.contains(&CheckCode::F622);
if let Some(check) = pyflakes::checks::starred_expressions(
elts,
check_too_many_expressions,
check_two_starred_expressions,
Range::from_located(expr),
) {
self.add_check(check);
if self.settings.enabled.contains(&CheckCode::F621)
|| self.settings.enabled.contains(&CheckCode::F622)
{
if let Some(check) =
pyflakes::checks::starred_expressions(elts, Range::from_located(expr))
{
self.add_check(check);
}
}
}
}
@@ -1279,17 +1276,10 @@ where
}
}
ExprKind::Dict { keys, .. } => {
let check_repeated_literals = self.settings.enabled.contains(&CheckCode::F601);
let check_repeated_variables = self.settings.enabled.contains(&CheckCode::F602);
if check_repeated_literals || check_repeated_variables {
self.add_checks(
pyflakes::checks::repeated_keys(
keys,
check_repeated_literals,
check_repeated_variables,
)
.into_iter(),
);
if self.settings.enabled.contains(&CheckCode::F601)
|| self.settings.enabled.contains(&CheckCode::F602)
{
self.add_checks(pyflakes::checks::repeated_keys(keys).into_iter());
}
}
ExprKind::Yield { .. } | ExprKind::YieldFrom { .. } | ExprKind::Await { .. } => {
@@ -1328,13 +1318,10 @@ where
}
}
ExprKind::UnaryOp { op, operand } => {
let check_not_in = self.settings.enabled.contains(&CheckCode::E713);
let check_not_is = self.settings.enabled.contains(&CheckCode::E714);
if check_not_in || check_not_is {
self.add_checks(
pycodestyle::checks::not_tests(op, operand, check_not_in, check_not_is)
.into_iter(),
);
if self.settings.enabled.contains(&CheckCode::E713)
|| self.settings.enabled.contains(&CheckCode::E714)
{
self.add_checks(pycodestyle::checks::not_tests(op, operand).into_iter());
}
if self.settings.enabled.contains(&CheckCode::B002) {
@@ -1346,18 +1333,12 @@ where
ops,
comparators,
} => {
let check_none_comparisons = self.settings.enabled.contains(&CheckCode::E711);
let check_true_false_comparisons = self.settings.enabled.contains(&CheckCode::E712);
if check_none_comparisons || check_true_false_comparisons {
if self.settings.enabled.contains(&CheckCode::E711)
|| self.settings.enabled.contains(&CheckCode::E712)
{
self.add_checks(
pycodestyle::checks::literal_comparisons(
left,
ops,
comparators,
check_none_comparisons,
check_true_false_comparisons,
)
.into_iter(),
pycodestyle::checks::literal_comparisons(left, ops, comparators)
.into_iter(),
);
}
@@ -2388,17 +2369,15 @@ impl<'a> Checker<'a> {
while let Some((definition, visibility)) = self.definitions.pop() {
// flake8-annotations
if self.settings.enabled.contains(&CheckCode::ANN001)
|| self.settings.enabled.contains(&CheckCode::ANN002)
|| self.settings.enabled.contains(&CheckCode::ANN003)
|| self.settings.enabled.contains(&CheckCode::ANN201)
|| self.settings.enabled.contains(&CheckCode::ANN202)
|| self.settings.enabled.contains(&CheckCode::ANN001)
|| self.settings.enabled.contains(&CheckCode::ANN002)
|| self.settings.enabled.contains(&CheckCode::ANN003)
|| self.settings.enabled.contains(&CheckCode::ANN101)
|| self.settings.enabled.contains(&CheckCode::ANN102)
|| self.settings.enabled.contains(&CheckCode::ANN201)
|| self.settings.enabled.contains(&CheckCode::ANN202)
|| self.settings.enabled.contains(&CheckCode::ANN204)
|| self.settings.enabled.contains(&CheckCode::ANN205)
|| self.settings.enabled.contains(&CheckCode::ANN206)
{
flake8_annotations::plugins::definition(self, &definition, &visibility);
}

View File

@@ -40,6 +40,7 @@ pub fn check_lines(
settings: &Settings,
autofix: &fixer::Mode,
) {
let enforce_unnecessary_coding_comment = settings.enabled.contains(&CheckCode::U009);
let enforce_line_too_long = settings.enabled.contains(&CheckCode::E501);
let enforce_noqa = settings.enabled.contains(&CheckCode::M001);
@@ -58,24 +59,27 @@ pub fn check_lines(
.map(|lineno| lineno - 1)
.unwrap_or(lineno);
if lineno < 2 {
// PEP3120 makes utf-8 the default encoding.
if CODING_COMMENT_REGEX.is_match(line) {
let line_length = line.len();
let mut check = Check::new(
CheckKind::PEP3120UnnecessaryCodingComment,
Range {
location: Location::new(lineno + 1, 0),
end_location: Location::new(lineno + 1, line_length + 1),
},
);
if autofix.patch() {
check.amend(Fix::deletion(
Location::new(lineno + 1, 0),
Location::new(lineno + 1, line_length + 1),
));
// Enforce unnecessary coding comments (U009).
if enforce_unnecessary_coding_comment {
if lineno < 2 {
// PEP3120 makes utf-8 the default encoding.
if CODING_COMMENT_REGEX.is_match(line) {
let line_length = line.len();
let mut check = Check::new(
CheckKind::PEP3120UnnecessaryCodingComment,
Range {
location: Location::new(lineno + 1, 0),
end_location: Location::new(lineno + 1, line_length + 1),
},
);
if autofix.patch() {
check.amend(Fix::deletion(
Location::new(lineno + 1, 0),
Location::new(lineno + 1, line_length + 1),
));
}
line_checks.push(check);
}
line_checks.push(check);
}
}
@@ -109,7 +113,7 @@ pub fn check_lines(
}
}
// Enforce line length.
// Enforce line length violations (E501).
if enforce_line_too_long {
let line_length = line.chars().count();
if should_enforce_line_length(line, line_length, settings.line_length) {

View File

@@ -5,6 +5,7 @@ use rustpython_parser::lexer::{LexResult, Tok};
use crate::autofix::fixer;
use crate::checks::{Check, CheckCode};
use crate::lex::docstring_detection::StateMachine;
use crate::rules::checks::Context;
use crate::source_code_locator::SourceCodeLocator;
use crate::{flake8_quotes, pycodestyle, rules, Settings};
@@ -16,7 +17,8 @@ pub fn check_tokens(
autofix: &fixer::Mode,
) {
let enforce_ambiguous_unicode_character = settings.enabled.contains(&CheckCode::RUF001)
|| settings.enabled.contains(&CheckCode::RUF002);
|| settings.enabled.contains(&CheckCode::RUF002)
|| settings.enabled.contains(&CheckCode::RUF003);
let enforce_quotes = settings.enabled.contains(&CheckCode::Q000)
|| settings.enabled.contains(&CheckCode::Q001)
|| settings.enabled.contains(&CheckCode::Q002)
@@ -31,14 +33,22 @@ pub fn check_tokens(
false
};
// RUF001, RUF002
// RUF001, RUF002, RUF003
if enforce_ambiguous_unicode_character {
if matches!(tok, Tok::String { .. }) {
if matches!(tok, Tok::String { .. } | Tok::Comment) {
for check in rules::checks::ambiguous_unicode_character(
locator,
start,
end,
is_docstring,
if matches!(tok, Tok::String { .. }) {
if is_docstring {
Context::Docstring
} else {
Context::String
}
} else {
Context::Comment
},
autofix.patch(),
) {
if settings.enabled.contains(check.kind.code()) {

View File

@@ -202,6 +202,7 @@ pub enum CheckCode {
// Ruff
RUF001,
RUF002,
RUF003,
// Meta
M001,
}
@@ -462,6 +463,7 @@ pub enum CheckKind {
// Ruff
AmbiguousUnicodeCharacterString(char, char),
AmbiguousUnicodeCharacterDocstring(char, char),
AmbiguousUnicodeCharacterComment(char, char),
// Meta
UnusedNOQA(Option<Vec<String>>),
}
@@ -480,7 +482,8 @@ impl CheckCode {
| CheckCode::Q003
| CheckCode::W605
| CheckCode::RUF001
| CheckCode::RUF002 => &LintSource::Tokens,
| CheckCode::RUF002
| CheckCode::RUF003 => &LintSource::Tokens,
CheckCode::E902 => &LintSource::FileSystem,
_ => &LintSource::AST,
}
@@ -702,6 +705,7 @@ impl CheckCode {
// Ruff
CheckCode::RUF001 => CheckKind::AmbiguousUnicodeCharacterString('𝐁', 'B'),
CheckCode::RUF002 => CheckKind::AmbiguousUnicodeCharacterDocstring('𝐁', 'B'),
CheckCode::RUF003 => CheckKind::AmbiguousUnicodeCharacterComment('𝐁', 'B'),
// Meta
CheckCode::M001 => CheckKind::UnusedNOQA(None),
}
@@ -873,6 +877,7 @@ impl CheckCode {
CheckCode::N818 => CheckCategory::PEP8Naming,
CheckCode::RUF001 => CheckCategory::Ruff,
CheckCode::RUF002 => CheckCategory::Ruff,
CheckCode::RUF003 => CheckCategory::Ruff,
CheckCode::M001 => CheckCategory::Meta,
}
}
@@ -1058,6 +1063,7 @@ impl CheckKind {
// Ruff
CheckKind::AmbiguousUnicodeCharacterString(..) => &CheckCode::RUF001,
CheckKind::AmbiguousUnicodeCharacterDocstring(..) => &CheckCode::RUF002,
CheckKind::AmbiguousUnicodeCharacterComment(..) => &CheckCode::RUF003,
// Meta
CheckKind::UnusedNOQA(_) => &CheckCode::M001,
}
@@ -1606,6 +1612,12 @@ impl CheckKind {
'{representant}'?)"
)
}
CheckKind::AmbiguousUnicodeCharacterComment(confusable, representant) => {
format!(
"Comment contains ambiguous unicode character '{confusable}' (did you mean \
'{representant}'?)"
)
}
// Meta
CheckKind::UnusedNOQA(codes) => match codes {
None => "Unused `noqa` directive".to_string(),

View File

@@ -233,6 +233,7 @@ pub enum CheckCodePrefix {
RUF00,
RUF001,
RUF002,
RUF003,
T,
T2,
T20,
@@ -926,11 +927,12 @@ impl CheckCodePrefix {
CheckCodePrefix::Q001 => vec![CheckCode::Q001],
CheckCodePrefix::Q002 => vec![CheckCode::Q002],
CheckCodePrefix::Q003 => vec![CheckCode::Q003],
CheckCodePrefix::RUF => vec![CheckCode::RUF001, CheckCode::RUF002],
CheckCodePrefix::RUF0 => vec![CheckCode::RUF001, CheckCode::RUF002],
CheckCodePrefix::RUF00 => vec![CheckCode::RUF001, CheckCode::RUF002],
CheckCodePrefix::RUF => vec![CheckCode::RUF001, CheckCode::RUF002, CheckCode::RUF003],
CheckCodePrefix::RUF0 => vec![CheckCode::RUF001, CheckCode::RUF002, CheckCode::RUF003],
CheckCodePrefix::RUF00 => vec![CheckCode::RUF001, CheckCode::RUF002, CheckCode::RUF003],
CheckCodePrefix::RUF001 => vec![CheckCode::RUF001],
CheckCodePrefix::RUF002 => vec![CheckCode::RUF002],
CheckCodePrefix::RUF003 => vec![CheckCode::RUF003],
CheckCodePrefix::T => vec![CheckCode::T201, CheckCode::T203],
CheckCodePrefix::T2 => vec![CheckCode::T201, CheckCode::T203],
CheckCodePrefix::T20 => vec![CheckCode::T201, CheckCode::T203],
@@ -1218,6 +1220,7 @@ impl CheckCodePrefix {
CheckCodePrefix::RUF00 => PrefixSpecificity::Tens,
CheckCodePrefix::RUF001 => PrefixSpecificity::Explicit,
CheckCodePrefix::RUF002 => PrefixSpecificity::Explicit,
CheckCodePrefix::RUF003 => PrefixSpecificity::Explicit,
CheckCodePrefix::T => PrefixSpecificity::Category,
CheckCodePrefix::T2 => PrefixSpecificity::Hundreds,
CheckCodePrefix::T20 => PrefixSpecificity::Tens,

View File

@@ -4,7 +4,7 @@ use crate::ast::types::Range;
use crate::ast::visitor;
use crate::ast::visitor::Visitor;
use crate::check_ast::Checker;
use crate::checks::{CheckCode, CheckKind};
use crate::checks::CheckKind;
use crate::docstrings::definition::{Definition, DefinitionKind};
use crate::visibility::Visibility;
use crate::{visibility, Check};
@@ -92,12 +92,10 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
if !(checker.settings.flake8_annotations.suppress_dummy_args
&& checker.settings.dummy_variable_rgx.is_match(&arg.node.arg))
{
if checker.settings.enabled.contains(&CheckCode::ANN001) {
checker.add_check(Check::new(
CheckKind::MissingTypeFunctionArgument(arg.node.arg.to_string()),
Range::from_located(arg),
));
}
checker.add_check(Check::new(
CheckKind::MissingTypeFunctionArgument(arg.node.arg.to_string()),
Range::from_located(arg),
));
}
}
}
@@ -108,12 +106,10 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
if !(checker.settings.flake8_annotations.suppress_dummy_args
&& checker.settings.dummy_variable_rgx.is_match(&arg.node.arg))
{
if checker.settings.enabled.contains(&CheckCode::ANN002) {
checker.add_check(Check::new(
CheckKind::MissingTypeArgs(arg.node.arg.to_string()),
Range::from_located(arg),
));
}
checker.add_check(Check::new(
CheckKind::MissingTypeArgs(arg.node.arg.to_string()),
Range::from_located(arg),
));
}
}
}
@@ -124,12 +120,10 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
if !(checker.settings.flake8_annotations.suppress_dummy_args
&& checker.settings.dummy_variable_rgx.is_match(&arg.node.arg))
{
if checker.settings.enabled.contains(&CheckCode::ANN003) {
checker.add_check(Check::new(
CheckKind::MissingTypeKwargs(arg.node.arg.to_string()),
Range::from_located(arg),
));
}
checker.add_check(Check::new(
CheckKind::MissingTypeKwargs(arg.node.arg.to_string()),
Range::from_located(arg),
));
}
}
}
@@ -146,20 +140,16 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
match visibility {
Visibility::Public => {
if checker.settings.enabled.contains(&CheckCode::ANN201) {
checker.add_check(Check::new(
CheckKind::MissingReturnTypePublicFunction(name.to_string()),
Range::from_located(stmt),
));
}
checker.add_check(Check::new(
CheckKind::MissingReturnTypePublicFunction(name.to_string()),
Range::from_located(stmt),
));
}
Visibility::Private => {
if checker.settings.enabled.contains(&CheckCode::ANN202) {
checker.add_check(Check::new(
CheckKind::MissingReturnTypePrivateFunction(name.to_string()),
Range::from_located(stmt),
));
}
checker.add_check(Check::new(
CheckKind::MissingReturnTypePrivateFunction(name.to_string()),
Range::from_located(stmt),
));
}
}
}
@@ -183,12 +173,10 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
if !(checker.settings.flake8_annotations.suppress_dummy_args
&& checker.settings.dummy_variable_rgx.is_match(&arg.node.arg))
{
if checker.settings.enabled.contains(&CheckCode::ANN001) {
checker.add_check(Check::new(
CheckKind::MissingTypeFunctionArgument(arg.node.arg.to_string()),
Range::from_located(arg),
));
}
checker.add_check(Check::new(
CheckKind::MissingTypeFunctionArgument(arg.node.arg.to_string()),
Range::from_located(arg),
));
}
} else {
has_any_typed_arg = true;
@@ -201,12 +189,10 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
if !(checker.settings.flake8_annotations.suppress_dummy_args
&& checker.settings.dummy_variable_rgx.is_match(&arg.node.arg))
{
if checker.settings.enabled.contains(&CheckCode::ANN002) {
checker.add_check(Check::new(
CheckKind::MissingTypeArgs(arg.node.arg.to_string()),
Range::from_located(arg),
));
}
checker.add_check(Check::new(
CheckKind::MissingTypeArgs(arg.node.arg.to_string()),
Range::from_located(arg),
));
}
} else {
has_any_typed_arg = true;
@@ -219,12 +205,10 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
if !(checker.settings.flake8_annotations.suppress_dummy_args
&& checker.settings.dummy_variable_rgx.is_match(&arg.node.arg))
{
if checker.settings.enabled.contains(&CheckCode::ANN003) {
checker.add_check(Check::new(
CheckKind::MissingTypeKwargs(arg.node.arg.to_string()),
Range::from_located(arg),
));
}
checker.add_check(Check::new(
CheckKind::MissingTypeKwargs(arg.node.arg.to_string()),
Range::from_located(arg),
));
}
} else {
has_any_typed_arg = true;
@@ -236,19 +220,15 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
if let Some(arg) = args.args.first() {
if arg.node.annotation.is_none() {
if visibility::is_classmethod(stmt) {
if checker.settings.enabled.contains(&CheckCode::ANN102) {
checker.add_check(Check::new(
CheckKind::MissingTypeCls(arg.node.arg.to_string()),
Range::from_located(arg),
));
}
checker.add_check(Check::new(
CheckKind::MissingTypeCls(arg.node.arg.to_string()),
Range::from_located(arg),
));
} else {
if checker.settings.enabled.contains(&CheckCode::ANN101) {
checker.add_check(Check::new(
CheckKind::MissingTypeSelf(arg.node.arg.to_string()),
Range::from_located(arg),
));
}
checker.add_check(Check::new(
CheckKind::MissingTypeSelf(arg.node.arg.to_string()),
Range::from_located(arg),
));
}
}
}
@@ -265,56 +245,43 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
}
if visibility::is_classmethod(stmt) {
if checker.settings.enabled.contains(&CheckCode::ANN206) {
checker.add_check(Check::new(
CheckKind::MissingReturnTypeClassMethod(name.to_string()),
Range::from_located(stmt),
));
}
checker.add_check(Check::new(
CheckKind::MissingReturnTypeClassMethod(name.to_string()),
Range::from_located(stmt),
));
} else if visibility::is_staticmethod(stmt) {
if checker.settings.enabled.contains(&CheckCode::ANN205) {
checker.add_check(Check::new(
CheckKind::MissingReturnTypeStaticMethod(name.to_string()),
Range::from_located(stmt),
));
}
checker.add_check(Check::new(
CheckKind::MissingReturnTypeStaticMethod(name.to_string()),
Range::from_located(stmt),
));
} else if visibility::is_magic(stmt) {
if checker.settings.enabled.contains(&CheckCode::ANN204) {
checker.add_check(Check::new(
CheckKind::MissingReturnTypeMagicMethod(name.to_string()),
Range::from_located(stmt),
));
} else if visibility::is_init(stmt) {
// Allow omission of return annotation in `__init__` functions, as long as at
// least one argument is typed.
if !(checker.settings.flake8_annotations.mypy_init_return && has_any_typed_arg)
{
checker.add_check(Check::new(
CheckKind::MissingReturnTypeMagicMethod(name.to_string()),
Range::from_located(stmt),
));
}
} else if visibility::is_init(stmt) {
// Allow omission of return annotation in `__init__` functions, as long as at
// least one argument is typed.
if checker.settings.enabled.contains(&CheckCode::ANN204) {
if !(checker.settings.flake8_annotations.mypy_init_return
&& has_any_typed_arg)
{
checker.add_check(Check::new(
CheckKind::MissingReturnTypeMagicMethod(name.to_string()),
Range::from_located(stmt),
));
}
}
} else {
match visibility {
Visibility::Public => {
if checker.settings.enabled.contains(&CheckCode::ANN201) {
checker.add_check(Check::new(
CheckKind::MissingReturnTypePublicFunction(name.to_string()),
Range::from_located(stmt),
));
}
checker.add_check(Check::new(
CheckKind::MissingReturnTypePublicFunction(name.to_string()),
Range::from_located(stmt),
));
}
Visibility::Private => {
if checker.settings.enabled.contains(&CheckCode::ANN202) {
checker.add_check(Check::new(
CheckKind::MissingReturnTypePrivateFunction(name.to_string()),
Range::from_located(stmt),
));
}
checker.add_check(Check::new(
CheckKind::MissingReturnTypePrivateFunction(name.to_string()),
Range::from_located(stmt),
));
}
}
}

View File

@@ -5,10 +5,10 @@ use crate::check_ast::Checker;
use crate::checks::{Check, CheckKind};
pub fn useless_comparison(checker: &mut Checker, expr: &Expr) {
if let ExprKind::Compare { left, .. } = &expr.node {
if matches!(expr.node, ExprKind::Compare { .. }) {
checker.add_check(Check::new(
CheckKind::UselessComparison,
Range::from_located(left),
Range::from_located(expr),
));
}
}

View File

@@ -4,24 +4,18 @@ use crate::ast::types::Range;
use crate::checks::{Check, CheckKind};
/// Check whether a function call is a `print` or `pprint` invocation
pub fn print_call(
expr: &Expr,
func: &Expr,
check_print: bool,
check_pprint: bool,
location: Range,
) -> Option<Check> {
pub fn print_call(expr: &Expr, func: &Expr, location: Range) -> Option<Check> {
if let ExprKind::Name { id, .. } = &func.node {
if check_print && id == "print" {
if id == "print" {
return Some(Check::new(CheckKind::PrintFound, Range::from_located(expr)));
} else if check_pprint && id == "pprint" {
} else if id == "pprint" {
return Some(Check::new(CheckKind::PPrintFound, location));
}
}
if let ExprKind::Attribute { value, attr, .. } = &func.node {
if let ExprKind::Name { id, .. } = &value.node {
if check_pprint && id == "pprint" && attr == "pprint" {
if id == "pprint" && attr == "pprint" {
return Some(Check::new(CheckKind::PPrintFound, location));
}
}

View File

@@ -4,17 +4,10 @@ use rustpython_ast::{Expr, Stmt, StmtKind};
use crate::ast::types::Range;
use crate::autofix::helpers;
use crate::check_ast::Checker;
use crate::checks::CheckCode;
use crate::flake8_print::checks;
pub fn print_call(checker: &mut Checker, expr: &Expr, func: &Expr) {
if let Some(mut check) = checks::print_call(
expr,
func,
checker.settings.enabled.contains(&CheckCode::T201),
checker.settings.enabled.contains(&CheckCode::T203),
Range::from_located(expr),
) {
if let Some(mut check) = checks::print_call(expr, func, Range::from_located(expr)) {
if checker.patch() {
let context = checker.binding_context();
if matches!(

View File

@@ -98,6 +98,12 @@ pub(crate) fn check_path(
// Run the lines-based checks.
check_lines(&mut checks, contents, noqa_line_for, settings, autofix);
// Filter out any disabled checks. Throughout the codebase, we skip work based
// on the set of enabled checks, but we don't _guarantee_ that disabled
// checks aren't added. (Sometimes, it's not worth repeatedly checking the
// code list for similar checks.)
checks.retain(|check| settings.enabled.contains(check.kind.code()));
// Create path ignores.
if !checks.is_empty() && !settings.per_file_ignores.is_empty() {
let ignores = fs::ignores_from_path(path, &settings.per_file_ignores)?;
@@ -452,6 +458,7 @@ mod tests {
#[test_case(CheckCode::W605, Path::new("W605_1.py"); "W605_1")]
#[test_case(CheckCode::RUF001, Path::new("RUF001.py"); "RUF001")]
#[test_case(CheckCode::RUF002, Path::new("RUF002.py"); "RUF002")]
#[test_case(CheckCode::RUF003, Path::new("RUF003.py"); "RUF003")]
fn checks(check_code: CheckCode, path: &Path) -> Result<()> {
let snapshot = format!("{}_{}", check_code.as_ref(), path.to_string_lossy());
let mut checks = check_path(

View File

@@ -56,12 +56,7 @@ pub fn do_not_assign_lambda(value: &Expr, location: Range) -> Option<Check> {
}
/// E713, E714
pub fn not_tests(
op: &Unaryop,
operand: &Expr,
check_not_in: bool,
check_not_is: bool,
) -> Vec<Check> {
pub fn not_tests(op: &Unaryop, operand: &Expr) -> Vec<Check> {
let mut checks: Vec<Check> = vec![];
if matches!(op, Unaryop::Not) {
@@ -69,20 +64,16 @@ pub fn not_tests(
for op in ops {
match op {
Cmpop::In => {
if check_not_in {
checks.push(Check::new(
CheckKind::NotInTest,
Range::from_located(operand),
));
}
checks.push(Check::new(
CheckKind::NotInTest,
Range::from_located(operand),
));
}
Cmpop::Is => {
if check_not_is {
checks.push(Check::new(
CheckKind::NotIsTest,
Range::from_located(operand),
));
}
checks.push(Check::new(
CheckKind::NotIsTest,
Range::from_located(operand),
));
}
_ => {}
}
@@ -94,28 +85,20 @@ pub fn not_tests(
}
/// E711, E712
pub fn literal_comparisons(
left: &Expr,
ops: &[Cmpop],
comparators: &[Expr],
check_none_comparisons: bool,
check_true_false_comparisons: bool,
) -> Vec<Check> {
pub fn literal_comparisons(left: &Expr, ops: &[Cmpop], comparators: &[Expr]) -> Vec<Check> {
let mut checks: Vec<Check> = vec![];
let op = ops.first().unwrap();
let comparator = left;
// Check `left`.
if check_none_comparisons
&& matches!(
comparator.node,
ExprKind::Constant {
value: Constant::None,
kind: None
}
)
{
if matches!(
comparator.node,
ExprKind::Constant {
value: Constant::None,
kind: None
}
) {
if matches!(op, Cmpop::Eq) {
checks.push(Check::new(
CheckKind::NoneComparison(RejectedCmpop::Eq),
@@ -130,7 +113,48 @@ pub fn literal_comparisons(
}
}
if check_true_false_comparisons {
if let ExprKind::Constant {
value: Constant::Bool(value),
kind: None,
} = comparator.node
{
if matches!(op, Cmpop::Eq) {
checks.push(Check::new(
CheckKind::TrueFalseComparison(value, RejectedCmpop::Eq),
Range::from_located(comparator),
));
}
if matches!(op, Cmpop::NotEq) {
checks.push(Check::new(
CheckKind::TrueFalseComparison(value, RejectedCmpop::NotEq),
Range::from_located(comparator),
));
}
}
// Check each comparator in order.
for (op, comparator) in izip!(ops, comparators) {
if matches!(
comparator.node,
ExprKind::Constant {
value: Constant::None,
kind: None
}
) {
if matches!(op, Cmpop::Eq) {
checks.push(Check::new(
CheckKind::NoneComparison(RejectedCmpop::Eq),
Range::from_located(comparator),
));
}
if matches!(op, Cmpop::NotEq) {
checks.push(Check::new(
CheckKind::NoneComparison(RejectedCmpop::NotEq),
Range::from_located(comparator),
));
}
}
if let ExprKind::Constant {
value: Constant::Bool(value),
kind: None,
@@ -151,53 +175,6 @@ pub fn literal_comparisons(
}
}
// Check each comparator in order.
for (op, comparator) in izip!(ops, comparators) {
if check_none_comparisons
&& matches!(
comparator.node,
ExprKind::Constant {
value: Constant::None,
kind: None
}
)
{
if matches!(op, Cmpop::Eq) {
checks.push(Check::new(
CheckKind::NoneComparison(RejectedCmpop::Eq),
Range::from_located(comparator),
));
}
if matches!(op, Cmpop::NotEq) {
checks.push(Check::new(
CheckKind::NoneComparison(RejectedCmpop::NotEq),
Range::from_located(comparator),
));
}
}
if check_true_false_comparisons {
if let ExprKind::Constant {
value: Constant::Bool(value),
kind: None,
} = comparator.node
{
if matches!(op, Cmpop::Eq) {
checks.push(Check::new(
CheckKind::TrueFalseComparison(value, RejectedCmpop::Eq),
Range::from_located(comparator),
));
}
if matches!(op, Cmpop::NotEq) {
checks.push(Check::new(
CheckKind::TrueFalseComparison(value, RejectedCmpop::NotEq),
Range::from_located(comparator),
));
}
}
}
}
checks
}

View File

@@ -143,11 +143,7 @@ fn convert_to_value(expr: &Expr) -> Option<DictionaryKey> {
}
/// F601, F602
pub fn repeated_keys(
keys: &[Expr],
check_repeated_literals: bool,
check_repeated_variables: bool,
) -> Vec<Check> {
pub fn repeated_keys(keys: &[Expr]) -> Vec<Check> {
let mut checks: Vec<Check> = vec![];
let num_keys = keys.len();
@@ -158,7 +154,7 @@ pub fn repeated_keys(
let v2 = convert_to_value(k2);
match (&v1, &v2) {
(Some(DictionaryKey::Constant(v1)), Some(DictionaryKey::Constant(v2))) => {
if check_repeated_literals && v1 == v2 {
if v1 == v2 {
checks.push(Check::new(
CheckKind::MultiValueRepeatedKeyLiteral,
Range::from_located(k2),
@@ -166,7 +162,7 @@ pub fn repeated_keys(
}
}
(Some(DictionaryKey::Variable(v1)), Some(DictionaryKey::Variable(v2))) => {
if check_repeated_variables && v1 == v2 {
if v1 == v2 {
checks.push(Check::new(
CheckKind::MultiValueRepeatedKeyVariable((*v2).to_string()),
Range::from_located(k2),
@@ -182,17 +178,12 @@ pub fn repeated_keys(
}
/// F621, F622
pub fn starred_expressions(
elts: &[Expr],
check_too_many_expressions: bool,
check_two_starred_expressions: bool,
location: Range,
) -> Option<Check> {
pub fn starred_expressions(elts: &[Expr], location: Range) -> Option<Check> {
let mut has_starred: bool = false;
let mut starred_index: Option<usize> = None;
for (index, elt) in elts.iter().enumerate() {
if matches!(elt.node, ExprKind::Starred { .. }) {
if has_starred && check_two_starred_expressions {
if has_starred {
return Some(Check::new(CheckKind::TwoStarredExpressions, location));
}
has_starred = true;
@@ -200,11 +191,9 @@ pub fn starred_expressions(
}
}
if check_too_many_expressions {
if let Some(starred_index) = starred_index {
if starred_index >= 1 << 8 || elts.len() - starred_index > 1 << 24 {
return Some(Check::new(CheckKind::ExpressionsInStarAssignment, location));
}
if let Some(starred_index) = starred_index {
if starred_index >= 1 << 8 || elts.len() - starred_index > 1 << 24 {
return Some(Check::new(CheckKind::ExpressionsInStarAssignment, location));
}
}

View File

@@ -1596,11 +1596,17 @@ static CONFUSABLES: Lazy<BTreeMap<u32, u32>> = Lazy::new(|| {
])
});
pub enum Context {
String,
Docstring,
Comment,
}
pub fn ambiguous_unicode_character(
locator: &SourceCodeLocator,
start: &Location,
end: &Location,
is_docstring: bool,
context: Context,
fix: bool,
) -> Vec<Check> {
let mut checks = vec![];
@@ -1623,10 +1629,17 @@ pub fn ambiguous_unicode_character(
};
let end_location = Location::new(location.row(), location.column() + 1);
let mut check = Check::new(
if is_docstring {
CheckKind::AmbiguousUnicodeCharacterDocstring(current_char, representant)
} else {
CheckKind::AmbiguousUnicodeCharacterString(current_char, representant)
match context {
Context::String => {
CheckKind::AmbiguousUnicodeCharacterString(current_char, representant)
}
Context::Docstring => CheckKind::AmbiguousUnicodeCharacterDocstring(
current_char,
representant,
),
Context::Comment => {
CheckKind::AmbiguousUnicodeCharacterComment(current_char, representant)
}
},
Range {
location,

View File

@@ -8,7 +8,7 @@ expression: checks
column: 0
end_location:
row: 3
column: 1
column: 6
fix: ~
- kind: UselessComparison
location:
@@ -16,7 +16,7 @@ expression: checks
column: 0
end_location:
row: 7
column: 1
column: 11
fix: ~
- kind: UselessComparison
location:
@@ -24,7 +24,7 @@ expression: checks
column: 4
end_location:
row: 17
column: 5
column: 15
fix: ~
- kind: UselessComparison
location:
@@ -32,6 +32,6 @@ expression: checks
column: 4
end_location:
row: 24
column: 5
column: 10
fix: ~

View File

@@ -5,7 +5,7 @@ expression: checks
- kind: NotInTest
location:
row: 2
column: 9
column: 7
end_location:
row: 2
column: 13
@@ -13,7 +13,7 @@ expression: checks
- kind: NotInTest
location:
row: 5
column: 11
column: 7
end_location:
row: 5
column: 15
@@ -21,7 +21,7 @@ expression: checks
- kind: NotInTest
location:
row: 8
column: 9
column: 7
end_location:
row: 8
column: 13
@@ -29,7 +29,7 @@ expression: checks
- kind: NotInTest
location:
row: 11
column: 24
column: 22
end_location:
row: 11
column: 28
@@ -37,7 +37,7 @@ expression: checks
- kind: NotInTest
location:
row: 14
column: 10
column: 8
end_location:
row: 14
column: 14

View File

@@ -5,7 +5,7 @@ expression: checks
- kind: NotIsTest
location:
row: 2
column: 9
column: 7
end_location:
row: 2
column: 13
@@ -13,7 +13,7 @@ expression: checks
- kind: NotIsTest
location:
row: 5
column: 11
column: 7
end_location:
row: 5
column: 15
@@ -21,7 +21,7 @@ expression: checks
- kind: NotIsTest
location:
row: 8
column: 9
column: 7
end_location:
row: 8
column: 22

View File

@@ -5,7 +5,7 @@ expression: checks
- kind: TypeComparison
location:
row: 2
column: 13
column: 3
end_location:
row: 2
column: 24
@@ -13,7 +13,7 @@ expression: checks
- kind: TypeComparison
location:
row: 5
column: 13
column: 3
end_location:
row: 5
column: 24
@@ -21,7 +21,7 @@ expression: checks
- kind: TypeComparison
location:
row: 10
column: 7
column: 3
end_location:
row: 10
column: 23
@@ -29,7 +29,7 @@ expression: checks
- kind: TypeComparison
location:
row: 15
column: 13
column: 3
end_location:
row: 15
column: 34
@@ -37,7 +37,7 @@ expression: checks
- kind: TypeComparison
location:
row: 18
column: 17
column: 7
end_location:
row: 18
column: 31
@@ -45,7 +45,7 @@ expression: checks
- kind: TypeComparison
location:
row: 18
column: 45
column: 35
end_location:
row: 18
column: 58
@@ -53,7 +53,7 @@ expression: checks
- kind: TypeComparison
location:
row: 20
column: 17
column: 7
end_location:
row: 20
column: 28
@@ -61,7 +61,7 @@ expression: checks
- kind: TypeComparison
location:
row: 22
column: 17
column: 7
end_location:
row: 22
column: 28
@@ -69,7 +69,7 @@ expression: checks
- kind: TypeComparison
location:
row: 24
column: 17
column: 7
end_location:
row: 24
column: 30
@@ -77,7 +77,7 @@ expression: checks
- kind: TypeComparison
location:
row: 26
column: 17
column: 7
end_location:
row: 26
column: 29
@@ -85,7 +85,7 @@ expression: checks
- kind: TypeComparison
location:
row: 28
column: 17
column: 7
end_location:
row: 28
column: 30
@@ -93,7 +93,7 @@ expression: checks
- kind: TypeComparison
location:
row: 30
column: 17
column: 7
end_location:
row: 30
column: 30
@@ -101,7 +101,7 @@ expression: checks
- kind: TypeComparison
location:
row: 32
column: 17
column: 7
end_location:
row: 32
column: 34
@@ -109,7 +109,7 @@ expression: checks
- kind: TypeComparison
location:
row: 34
column: 17
column: 7
end_location:
row: 38
column: 1
@@ -117,7 +117,7 @@ expression: checks
- kind: TypeComparison
location:
row: 40
column: 17
column: 7
end_location:
row: 40
column: 28
@@ -125,7 +125,7 @@ expression: checks
- kind: TypeComparison
location:
row: 42
column: 17
column: 7
end_location:
row: 42
column: 30

View File

@@ -5,7 +5,7 @@ expression: checks
- kind: IsLiteral
location:
row: 1
column: 5
column: 3
end_location:
row: 1
column: 13
@@ -22,7 +22,7 @@ expression: checks
- kind: IsLiteral
location:
row: 4
column: 7
column: 3
end_location:
row: 4
column: 15
@@ -39,7 +39,7 @@ expression: checks
- kind: IsLiteral
location:
row: 7
column: 9
column: 3
end_location:
row: 7
column: 17

View File

@@ -8,18 +8,18 @@ expression: checks
- )
location:
row: 5
column: 53
column: 55
end_location:
row: 5
column: 54
column: 56
fix:
patch:
content: )
location:
row: 5
column: 53
column: 55
end_location:
row: 5
column: 54
column: 56
applied: false

View File

@@ -0,0 +1,25 @@
---
source: src/linter.rs
expression: checks
---
- kind:
AmbiguousUnicodeCharacterComment:
-
- /
location:
row: 6
column: 61
end_location:
row: 6
column: 62
fix:
patch:
content: /
location:
row: 6
column: 61
end_location:
row: 6
column: 62
applied: false

View File

@@ -269,7 +269,7 @@ expression: checks
row: 98
column: 4
end_location:
row: 100
row: 99
column: 4
applied: false
- kind: