Compare commits

...

7 Commits

Author SHA1 Message Date
Charlie Marsh
72453695d6 Bump version to 0.0.144 2022-11-28 20:11:08 -05:00
Charlie Marsh
1617d715f2 Allow long lines that consist of only a URL (#952) 2022-11-28 20:10:21 -05:00
pwoolvett
c4a7344791 fix(flake8_boolean_trap): add allowlist for dict methods (#943) 2022-11-28 16:17:01 -05:00
Charlie Marsh
ea9acda732 Bump version to 0.0.143 2022-11-28 15:42:25 -05:00
Anders Kaseorg
6c8021e970 Fix clippy::manual_let_else (pedantic) (#939) 2022-11-28 09:52:59 -05:00
Charlie Marsh
61b6ad46ea Allow @override methods to be undocumented (#941) 2022-11-28 09:52:12 -05:00
Anders Kaseorg
041d8108e6 Don’t require files with --explain or --generate-shell-completion (#937) 2022-11-28 00:40:20 -05:00
44 changed files with 371 additions and 343 deletions

View File

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

6
Cargo.lock generated
View File

@@ -700,7 +700,7 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
[[package]]
name = "flake8-to-ruff"
version = "0.0.142-dev.0"
version = "0.0.144-dev.0"
dependencies = [
"anyhow",
"clap 4.0.22",
@@ -1805,7 +1805,7 @@ dependencies = [
[[package]]
name = "ruff"
version = "0.0.142"
version = "0.0.144"
dependencies = [
"annotate-snippets 0.9.1",
"anyhow",
@@ -1856,7 +1856,7 @@ dependencies = [
[[package]]
name = "ruff_dev"
version = "0.0.142"
version = "0.0.144"
dependencies = [
"anyhow",
"clap 4.0.22",

View File

@@ -6,7 +6,7 @@ members = [
[package]
name = "ruff"
version = "0.0.142"
version = "0.0.144"
edition = "2021"
rust-version = "1.65.0"

View File

@@ -134,7 +134,7 @@ Ruff also works with [pre-commit](https://pre-commit.com):
```yaml
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.142
rev: v0.0.144
hooks:
- id: ruff
```

View File

@@ -771,7 +771,7 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
[[package]]
name = "flake8_to_ruff"
version = "0.0.142"
version = "0.0.144"
dependencies = [
"anyhow",
"clap",
@@ -1975,7 +1975,7 @@ dependencies = [
[[package]]
name = "ruff"
version = "0.0.142"
version = "0.0.144"
dependencies = [
"anyhow",
"bincode",

View File

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

View File

@@ -3,6 +3,7 @@ from functools import wraps
import os
from .expected import Expectation
from typing import overload
from typing_extensions import override
expectation = Expectation()
@@ -42,9 +43,13 @@ class class_:
"D418: Function/ Method decorated with @overload"
" shouldn't contain a docstring")
@override
def overridden_method(a):
return str(a)
@property
def foo(self):
"""The foo of the thing, which isn't in imperitive mood."""
"""The foo of the thing, which isn't in imperative mood."""
return "hello"
@expect('D102: Missing docstring in public method')

View File

@@ -52,3 +52,6 @@ sit amet consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labor
# OK
# A very long URL: https://loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong.url.com
# OK
# https://loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong.url.com

View File

@@ -38,5 +38,20 @@ def function(
def used(do):
return do
used("a", True)
used(do=True)
# Avoid FBT003 for explicitly allowed methods.
"""
FBT003 Boolean positional value on dict
"""
a = {"a": "b"}
a.get("hello", False)
{}.get("hello", False)
{}.setdefault("hello", True)
{}.pop("hello", False)
{}.pop(True, False)
dict.fromkeys(("world",), True)
{}.deploy(True, False)

View File

@@ -1,6 +1,6 @@
[package]
name = "ruff_dev"
version = "0.0.142"
version = "0.0.144"
edition = "2021"
[dependencies]

View File

@@ -1638,7 +1638,7 @@ where
// flake8-boolean-trap
if self.settings.enabled.contains(&CheckCode::FBT003) {
flake8_boolean_trap::plugins::check_boolean_positional_value_in_function_call(
self, args,
self, args, func,
);
}
if let ExprKind::Name { id, ctx } = &func.node {

View File

@@ -25,7 +25,7 @@ fn should_enforce_line_length(line: &str, length: usize, limit: usize) -> bool {
if let (Some(first), Some(_)) = (chunks.next(), chunks.next()) {
// Do not enforce the line length for commented lines that end with a URL
// or contain only a single word.
!(first == "#" && chunks.last().map_or(false, |c| URL_REGEX.is_match(c)))
!(first == "#" && chunks.last().map_or(true, |c| URL_REGEX.is_match(c)))
} else {
// Single word / no printable chars - no way to make the line shorter
false

View File

@@ -15,7 +15,7 @@ use crate::settings::types::{FilePattern, PatternPrefixPair, PerFileIgnore, Pyth
#[command(version)]
#[allow(clippy::struct_excessive_bools)]
pub struct Cli {
#[arg(required = true)]
#[arg(required_unless_present_any = ["explain", "generate_shell_completion"])]
pub files: Vec<PathBuf>,
/// Path to the `pyproject.toml` file to use for configuration.
#[arg(long)]

View File

@@ -5,6 +5,19 @@ use crate::ast::types::Range;
use crate::check_ast::Checker;
use crate::checks::{Check, CheckKind};
const FUNC_NAME_ALLOWLIST: &[&str] = &["get", "setdefault", "pop", "fromkeys"];
/// Returns `true` if an argument is allowed to use a boolean trap. To return
/// `true`, the function name must be explicitly allowed, and the argument must
/// be either the first or second argument in the call.
fn allow_boolean_trap(func: &Expr) -> bool {
if let ExprKind::Attribute { attr, .. } = &func.node {
FUNC_NAME_ALLOWLIST.contains(&attr.as_ref())
} else {
false
}
}
fn is_boolean_arg(arg: &Expr) -> bool {
matches!(
&arg.node,
@@ -60,8 +73,15 @@ pub fn check_boolean_default_value_in_function_definition(
}
}
pub fn check_boolean_positional_value_in_function_call(checker: &mut Checker, args: &[Expr]) {
for arg in args {
pub fn check_boolean_positional_value_in_function_call(
checker: &mut Checker,
args: &[Expr],
func: &Expr,
) {
for (index, arg) in args.iter().enumerate() {
if index < 2 && allow_boolean_trap(func) {
continue;
}
add_if_boolean(
checker,
arg,

View File

@@ -39,9 +39,7 @@ pub fn fix_unnecessary_generator_list(
let call = match_call(body)?;
let arg = match_arg(call)?;
let generator_exp = if let Expression::GeneratorExp(generator_exp) = &arg.value {
generator_exp
} else {
let Expression::GeneratorExp(generator_exp) = &arg.value else {
return Err(anyhow::anyhow!(
"Expected node to be: Expression::GeneratorExp"
));
@@ -82,9 +80,7 @@ pub fn fix_unnecessary_generator_set(
let call = match_call(body)?;
let arg = match_arg(call)?;
let generator_exp = if let Expression::GeneratorExp(generator_exp) = &arg.value {
generator_exp
} else {
let Expression::GeneratorExp(generator_exp) = &arg.value else {
return Err(anyhow::anyhow!(
"Expected node to be: Expression::GeneratorExp"
));
@@ -126,28 +122,20 @@ pub fn fix_unnecessary_generator_dict(
let arg = match_arg(call)?;
// Extract the (k, v) from `(k, v) for ...`.
let generator_exp = if let Expression::GeneratorExp(generator_exp) = &arg.value {
generator_exp
} else {
let Expression::GeneratorExp(generator_exp) = &arg.value else {
return Err(anyhow::anyhow!(
"Expected node to be: Expression::GeneratorExp"
));
};
let tuple = if let Expression::Tuple(tuple) = &generator_exp.elt.as_ref() {
tuple
} else {
let Expression::Tuple(tuple) = &generator_exp.elt.as_ref() else {
return Err(anyhow::anyhow!("Expected node to be: Expression::Tuple"));
};
let key = if let Some(Element::Simple { value, .. }) = &tuple.elements.get(0) {
value
} else {
let Some(Element::Simple { value: key, .. }) = &tuple.elements.get(0) else {
return Err(anyhow::anyhow!(
"Expected tuple to contain a key as the first element"
));
};
let value = if let Some(Element::Simple { value, .. }) = &tuple.elements.get(1) {
value
} else {
let Some(Element::Simple { value, .. }) = &tuple.elements.get(1) else {
return Err(anyhow::anyhow!(
"Expected tuple to contain a key as the second element"
));
@@ -192,9 +180,7 @@ pub fn fix_unnecessary_list_comprehension_set(
let call = match_call(body)?;
let arg = match_arg(call)?;
let list_comp = if let Expression::ListComp(list_comp) = &arg.value {
list_comp
} else {
let Expression::ListComp(list_comp) = &arg.value else {
return Err(anyhow::anyhow!("Expected node to be: Expression::ListComp"));
};
@@ -233,25 +219,18 @@ pub fn fix_unnecessary_list_comprehension_dict(
let call = match_call(body)?;
let arg = match_arg(call)?;
let list_comp = if let Expression::ListComp(list_comp) = &arg.value {
list_comp
} else {
let Expression::ListComp(list_comp) = &arg.value else {
return Err(anyhow::anyhow!("Expected node to be: Expression::ListComp"));
};
let tuple = if let Expression::Tuple(tuple) = &*list_comp.elt {
tuple
} else {
let Expression::Tuple(tuple) = &*list_comp.elt else {
return Err(anyhow::anyhow!("Expected node to be: Expression::Tuple"));
};
let (key, comma, value) = match &tuple.elements[..] {
[Element::Simple {
let [Element::Simple {
value: key,
comma: Some(comma),
}, Element::Simple { value, .. }] => (key, comma, value),
_ => return Err(anyhow::anyhow!("Expected tuple with two elements")),
};
}, Element::Simple { value, .. }] = &tuple.elements[..] else { return Err(anyhow::anyhow!("Expected tuple with two elements")) };
body.value = Expression::DictComp(Box::new(DictComp {
key: Box::new(key.clone()),
@@ -409,9 +388,7 @@ pub fn fix_unnecessary_collection_call(
let mut tree = match_module(&module_text)?;
let mut body = match_expr(&mut tree)?;
let call = match_call(body)?;
let name = if let Expression::Name(name) = &call.func.as_ref() {
name
} else {
let Expression::Name(name) = &call.func.as_ref() else {
return Err(anyhow::anyhow!("Expected node to be: Expression::Name"));
};

View File

@@ -193,6 +193,16 @@ fn inner_main() -> Result<ExitCode> {
let log_level = extract_log_level(&cli);
set_up_logging(&log_level)?;
if let Some(code) = cli.explain {
commands::explain(&code, cli.format)?;
return Ok(ExitCode::SUCCESS);
}
if let Some(shell) = cli.generate_shell_completion {
shell.generate(&mut Cli::command(), &mut std::io::stdout());
return Ok(ExitCode::SUCCESS);
}
// Find the project root and pyproject.toml.
let project_root = pyproject::find_project_root(&cli.files);
match &project_root {
@@ -256,16 +266,6 @@ fn inner_main() -> Result<ExitCode> {
configuration.show_source = true;
}
if let Some(code) = cli.explain {
commands::explain(&code, cli.format)?;
return Ok(ExitCode::SUCCESS);
}
if let Some(shell) = cli.generate_shell_completion {
shell.generate(&mut Cli::command(), &mut std::io::stdout());
return Ok(ExitCode::SUCCESS);
}
if cli.show_settings && cli.show_files {
eprintln!("Error: specify --show-settings or show-files (not both).");
return Ok(ExitCode::FAILURE);

View File

@@ -15,7 +15,7 @@ use crate::docstrings::constants;
use crate::docstrings::definition::{Definition, DefinitionKind};
use crate::docstrings::sections::{section_contexts, SectionContext};
use crate::docstrings::styles::SectionStyle;
use crate::visibility::{is_init, is_magic, is_overload, is_staticmethod, Visibility};
use crate::visibility::{is_init, is_magic, is_overload, is_override, is_staticmethod, Visibility};
/// D100, D101, D102, D103, D104, D105, D106, D107
pub fn not_missing(
@@ -88,7 +88,7 @@ pub fn not_missing(
}
}
DefinitionKind::Method(stmt) => {
if is_overload(stmt) {
if is_overload(stmt) || is_override(stmt) {
true
} else if is_magic(stmt) {
if checker.settings.enabled.contains(&CheckCode::D105) {

View File

@@ -22,14 +22,10 @@ pub fn remove_unused_imports(
let module_text = locator.slice_source_code_range(&Range::from_located(stmt));
let mut tree = match_module(&module_text)?;
let body = if let Some(Statement::Simple(body)) = tree.body.first_mut() {
body
} else {
let Some(Statement::Simple(body)) = tree.body.first_mut() else {
return Err(anyhow::anyhow!("Expected node to be: Statement::Simple"));
};
let body = if let Some(SmallStatement::Import(body)) = body.body.first_mut() {
body
} else {
let Some(SmallStatement::Import(body)) = body.body.first_mut() else {
return Err(anyhow::anyhow!(
"Expected node to be: SmallStatement::ImportFrom"
));
@@ -80,22 +76,16 @@ pub fn remove_unused_import_froms(
let module_text = locator.slice_source_code_range(&Range::from_located(stmt));
let mut tree = match_module(&module_text)?;
let body = if let Some(Statement::Simple(body)) = tree.body.first_mut() {
body
} else {
let Some(Statement::Simple(body)) = tree.body.first_mut() else {
return Err(anyhow::anyhow!("Expected node to be: Statement::Simple"));
};
let body = if let Some(SmallStatement::ImportFrom(body)) = body.body.first_mut() {
body
} else {
let Some(SmallStatement::ImportFrom(body)) = body.body.first_mut() else {
return Err(anyhow::anyhow!(
"Expected node to be: SmallStatement::ImportFrom"
));
};
let aliases = if let ImportNames::Aliases(aliases) = &mut body.names {
aliases
} else {
let ImportNames::Aliases(aliases) = &mut body.names else {
return Err(anyhow::anyhow!("Expected node to be: Aliases"));
};

View File

@@ -111,10 +111,7 @@ pub fn remove_super_arguments(locator: &SourceCodeLocator, expr: &Expr) -> Optio
let range = Range::from_located(expr);
let contents = locator.slice_source_code_range(&range);
let mut tree = match libcst_native::parse_module(&contents, None) {
Ok(m) => m,
Err(_) => return None,
};
let mut tree = libcst_native::parse_module(&contents, None).ok()?;
if let Some(Statement::Simple(body)) = tree.body.first_mut() {
if let Some(SmallStatement::Expr(body)) = body.body.first_mut() {
@@ -150,22 +147,16 @@ pub fn remove_unnecessary_future_import(
let module_text = locator.slice_source_code_range(&Range::from_located(stmt));
let mut tree = match_module(&module_text)?;
let body = if let Some(Statement::Simple(body)) = tree.body.first_mut() {
body
} else {
let Some(Statement::Simple(body)) = tree.body.first_mut() else {
return Err(anyhow::anyhow!("Expected node to be: Statement::Simple"));
};
let body = if let Some(SmallStatement::ImportFrom(body)) = body.body.first_mut() {
body
} else {
let Some(SmallStatement::ImportFrom(body)) = body.body.first_mut() else {
return Err(anyhow::anyhow!(
"Expected node to be: SmallStatement::ImportFrom"
));
};
let aliases = if let ImportNames::Aliases(aliases) = &mut body.names {
aliases
} else {
let ImportNames::Aliases(aliases) = &mut body.names else {
return Err(anyhow::anyhow!("Expected node to be: Aliases"));
};

View File

@@ -4,10 +4,10 @@ expression: checks
---
- kind: PublicClass
location:
row: 14
row: 15
column: 0
end_location:
row: 67
row: 72
column: 0
fix: ~

View File

@@ -4,26 +4,26 @@ expression: checks
---
- kind: PublicMethod
location:
row: 22
row: 23
column: 4
end_location:
row: 25
row: 26
column: 4
fix: ~
- kind: PublicMethod
location:
row: 51
row: 56
column: 4
end_location:
row: 54
row: 59
column: 4
fix: ~
- kind: PublicMethod
location:
row: 63
row: 68
column: 4
end_location:
row: 67
row: 72
column: 0
fix: ~

View File

@@ -4,10 +4,10 @@ expression: checks
---
- kind: PublicFunction
location:
row: 395
row: 400
column: 0
end_location:
row: 396
row: 401
column: 0
fix: ~

View File

@@ -4,10 +4,10 @@ expression: checks
---
- kind: MagicMethod
location:
row: 59
row: 64
column: 4
end_location:
row: 62
row: 67
column: 4
fix: ~

View File

@@ -4,18 +4,18 @@ expression: checks
---
- kind: PublicInit
location:
row: 55
row: 60
column: 4
end_location:
row: 58
row: 63
column: 4
fix: ~
- kind: PublicInit
location:
row: 529
row: 534
column: 4
end_location:
row: 533
row: 538
column: 0
fix: ~

View File

@@ -5,69 +5,69 @@ expression: checks
- kind:
NoBlankLineBeforeFunction: 1
location:
row: 132
row: 137
column: 4
end_location:
row: 132
row: 137
column: 24
fix:
patch:
content: ""
location:
row: 131
row: 136
column: 0
end_location:
row: 132
row: 137
column: 0
- kind:
NoBlankLineBeforeFunction: 1
location:
row: 146
row: 151
column: 4
end_location:
row: 146
row: 151
column: 37
fix:
patch:
content: ""
location:
row: 145
row: 150
column: 0
end_location:
row: 146
row: 151
column: 0
- kind:
NoBlankLineBeforeFunction: 1
location:
row: 541
row: 546
column: 4
end_location:
row: 544
row: 549
column: 7
fix:
patch:
content: ""
location:
row: 540
row: 545
column: 0
end_location:
row: 541
row: 546
column: 0
- kind:
NoBlankLineBeforeFunction: 1
location:
row: 563
row: 568
column: 4
end_location:
row: 566
row: 571
column: 7
fix:
patch:
content: ""
location:
row: 562
row: 567
column: 0
end_location:
row: 563
row: 568
column: 0

View File

@@ -5,69 +5,69 @@ expression: checks
- kind:
NoBlankLineAfterFunction: 1
location:
row: 137
row: 142
column: 4
end_location:
row: 137
row: 142
column: 24
fix:
patch:
content: ""
location:
row: 138
row: 143
column: 0
end_location:
row: 139
row: 144
column: 0
- kind:
NoBlankLineAfterFunction: 1
location:
row: 146
row: 151
column: 4
end_location:
row: 146
row: 151
column: 37
fix:
patch:
content: ""
location:
row: 147
row: 152
column: 0
end_location:
row: 148
row: 153
column: 0
- kind:
NoBlankLineAfterFunction: 1
location:
row: 550
row: 555
column: 4
end_location:
row: 553
row: 558
column: 7
fix:
patch:
content: ""
location:
row: 554
row: 559
column: 0
end_location:
row: 555
row: 560
column: 0
- kind:
NoBlankLineAfterFunction: 1
location:
row: 563
row: 568
column: 4
end_location:
row: 566
row: 571
column: 7
fix:
patch:
content: ""
location:
row: 567
row: 572
column: 0
end_location:
row: 568
row: 573
column: 0

View File

@@ -5,52 +5,52 @@ expression: checks
- kind:
OneBlankLineBeforeClass: 0
location:
row: 156
row: 161
column: 4
end_location:
row: 156
row: 161
column: 32
fix:
patch:
content: "\n"
location:
row: 156
row: 161
column: 0
end_location:
row: 156
row: 161
column: 0
- kind:
OneBlankLineBeforeClass: 0
location:
row: 187
row: 192
column: 4
end_location:
row: 187
row: 192
column: 45
fix:
patch:
content: "\n"
location:
row: 187
row: 192
column: 0
end_location:
row: 187
row: 192
column: 0
- kind:
OneBlankLineBeforeClass: 0
location:
row: 521
row: 526
column: 4
end_location:
row: 527
row: 532
column: 7
fix:
patch:
content: "\n"
location:
row: 521
row: 526
column: 0
end_location:
row: 521
row: 526
column: 0

View File

@@ -5,35 +5,35 @@ expression: checks
- kind:
OneBlankLineAfterClass: 0
location:
row: 176
row: 181
column: 4
end_location:
row: 176
row: 181
column: 24
fix:
patch:
content: "\n"
location:
row: 177
row: 182
column: 0
end_location:
row: 177
row: 182
column: 0
- kind:
OneBlankLineAfterClass: 0
location:
row: 187
row: 192
column: 4
end_location:
row: 187
row: 192
column: 45
fix:
patch:
content: "\n"
location:
row: 188
row: 193
column: 0
end_location:
row: 188
row: 193
column: 0

View File

@@ -4,34 +4,34 @@ expression: checks
---
- kind: BlankLineAfterSummary
location:
row: 195
row: 200
column: 4
end_location:
row: 198
row: 203
column: 7
fix:
patch:
content: "\n"
location:
row: 196
row: 201
column: 0
end_location:
row: 196
row: 201
column: 0
- kind: BlankLineAfterSummary
location:
row: 205
row: 210
column: 4
end_location:
row: 210
row: 215
column: 7
fix:
patch:
content: "\n"
location:
row: 206
row: 211
column: 0
end_location:
row: 208
row: 213
column: 0

View File

@@ -4,34 +4,34 @@ expression: checks
---
- kind: NoUnderIndentation
location:
row: 227
row: 232
column: 0
end_location:
row: 227
row: 232
column: 0
fix:
patch:
content: " "
location:
row: 227
row: 232
column: 0
end_location:
row: 227
row: 232
column: 0
- kind: NoUnderIndentation
location:
row: 435
row: 440
column: 0
end_location:
row: 435
row: 440
column: 0
fix:
patch:
content: " "
location:
row: 435
row: 440
column: 0
end_location:
row: 435
row: 440
column: 4

View File

@@ -4,50 +4,50 @@ expression: checks
---
- kind: NoOverIndentation
location:
row: 247
row: 252
column: 0
end_location:
row: 247
row: 252
column: 0
fix:
patch:
content: " "
location:
row: 247
row: 252
column: 0
end_location:
row: 247
row: 252
column: 7
- kind: NoOverIndentation
location:
row: 259
row: 264
column: 0
end_location:
row: 259
row: 264
column: 0
fix:
patch:
content: " "
location:
row: 259
row: 264
column: 0
end_location:
row: 259
row: 264
column: 8
- kind: NoOverIndentation
location:
row: 267
row: 272
column: 0
end_location:
row: 267
row: 272
column: 0
fix:
patch:
content: " "
location:
row: 267
row: 272
column: 0
end_location:
row: 267
row: 272
column: 8

View File

@@ -4,18 +4,18 @@ expression: checks
---
- kind: NewLineAfterLastParagraph
location:
row: 276
row: 281
column: 4
end_location:
row: 278
row: 283
column: 19
fix:
patch:
content: "\n "
location:
row: 278
row: 283
column: 16
end_location:
row: 278
row: 283
column: 16

View File

@@ -4,50 +4,50 @@ expression: checks
---
- kind: NoSurroundingWhitespace
location:
row: 283
row: 288
column: 4
end_location:
row: 283
row: 288
column: 33
fix:
patch:
content: Whitespace at the end.
location:
row: 283
row: 288
column: 7
end_location:
row: 283
row: 288
column: 30
- kind: NoSurroundingWhitespace
location:
row: 288
row: 293
column: 4
end_location:
row: 288
row: 293
column: 37
fix:
patch:
content: Whitespace at everywhere.
location:
row: 288
row: 293
column: 7
end_location:
row: 288
row: 293
column: 34
- kind: NoSurroundingWhitespace
location:
row: 294
row: 299
column: 4
end_location:
row: 297
row: 302
column: 7
fix:
patch:
content: Whitespace at the beginning.
location:
row: 294
row: 299
column: 7
end_location:
row: 294
row: 299
column: 36

View File

@@ -5,35 +5,35 @@ expression: checks
- kind:
NoBlankLineBeforeClass: 1
location:
row: 165
row: 170
column: 4
end_location:
row: 165
row: 170
column: 29
fix:
patch:
content: ""
location:
row: 164
row: 169
column: 0
end_location:
row: 165
row: 170
column: 0
- kind:
NoBlankLineBeforeClass: 1
location:
row: 176
row: 181
column: 4
end_location:
row: 176
row: 181
column: 24
fix:
patch:
content: ""
location:
row: 175
row: 180
column: 0
end_location:
row: 176
row: 181
column: 0

View File

@@ -4,10 +4,10 @@ expression: checks
---
- kind: MultiLineSummaryFirstLine
location:
row: 124
row: 129
column: 4
end_location:
row: 126
row: 131
column: 7
fix: ~

View File

@@ -4,154 +4,154 @@ expression: checks
---
- kind: MultiLineSummarySecondLine
location:
row: 195
row: 200
column: 4
end_location:
row: 198
row: 203
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 205
column: 4
end_location:
row: 210
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
column: 4
end_location:
row: 215
column: 4
end_location:
row: 219
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 225
row: 220
column: 4
end_location:
row: 229
row: 224
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 235
row: 230
column: 4
end_location:
row: 239
row: 234
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 240
column: 4
end_location:
row: 244
column: 3
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 245
row: 250
column: 4
end_location:
row: 249
row: 254
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 255
row: 260
column: 4
end_location:
row: 259
row: 264
column: 11
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 265
row: 270
column: 4
end_location:
row: 269
row: 274
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 276
row: 281
column: 4
end_location:
row: 278
row: 283
column: 19
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 294
row: 299
column: 4
end_location:
row: 297
row: 302
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 338
column: 4
end_location:
row: 343
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 378
column: 4
end_location:
row: 381
row: 348
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 387
row: 383
column: 4
end_location:
row: 391
row: 386
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 433
row: 392
column: 4
end_location:
row: 396
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 438
column: 36
end_location:
row: 436
row: 441
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 445
row: 450
column: 4
end_location:
row: 449
row: 454
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 521
row: 526
column: 4
end_location:
row: 527
row: 532
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 541
row: 546
column: 4
end_location:
row: 544
row: 549
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 550
row: 555
column: 4
end_location:
row: 553
row: 558
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 563
row: 568
column: 4
end_location:
row: 566
row: 571
column: 7
fix: ~

View File

@@ -2,14 +2,6 @@
source: src/linter.rs
expression: checks
---
- kind: UsesTripleQuotes
location:
row: 302
column: 4
end_location:
row: 302
column: 19
fix: ~
- kind: UsesTripleQuotes
location:
row: 307
@@ -24,7 +16,7 @@ expression: checks
column: 4
end_location:
row: 312
column: 15
column: 19
fix: ~
- kind: UsesTripleQuotes
location:
@@ -36,10 +28,18 @@ expression: checks
fix: ~
- kind: UsesTripleQuotes
location:
row: 323
row: 322
column: 4
end_location:
row: 323
row: 322
column: 15
fix: ~
- kind: UsesTripleQuotes
location:
row: 328
column: 4
end_location:
row: 328
column: 16
fix: ~

View File

@@ -4,60 +4,52 @@ expression: checks
---
- kind: EndsInPeriod
location:
row: 350
row: 355
column: 4
end_location:
row: 350
row: 355
column: 17
fix: ~
- kind: EndsInPeriod
location:
row: 401
row: 406
column: 24
end_location:
row: 401
row: 406
column: 39
fix: ~
- kind: EndsInPeriod
location:
row: 405
row: 410
column: 4
end_location:
row: 405
row: 410
column: 24
fix: ~
- kind: EndsInPeriod
location:
row: 411
row: 416
column: 4
end_location:
row: 411
row: 416
column: 24
fix: ~
- kind: EndsInPeriod
location:
row: 417
row: 422
column: 34
end_location:
row: 417
row: 422
column: 49
fix: ~
- kind: EndsInPeriod
location:
row: 424
row: 429
column: 48
end_location:
row: 424
row: 429
column: 63
fix: ~
- kind: EndsInPeriod
location:
row: 465
column: 4
end_location:
row: 465
column: 24
fix: ~
- kind: EndsInPeriod
location:
row: 470
@@ -76,34 +68,42 @@ expression: checks
fix: ~
- kind: EndsInPeriod
location:
row: 482
row: 480
column: 4
end_location:
row: 482
row: 480
column: 24
fix: ~
- kind: EndsInPeriod
location:
row: 504
row: 487
column: 4
end_location:
row: 504
row: 487
column: 24
fix: ~
- kind: EndsInPeriod
location:
row: 509
column: 4
end_location:
row: 509
column: 34
fix: ~
- kind: EndsInPeriod
location:
row: 509
row: 514
column: 4
end_location:
row: 509
row: 514
column: 33
fix: ~
- kind: EndsInPeriod
location:
row: 515
row: 520
column: 4
end_location:
row: 515
row: 520
column: 32
fix: ~

View File

@@ -4,10 +4,10 @@ expression: checks
---
- kind: NoSignature
location:
row: 373
row: 378
column: 4
end_location:
row: 373
row: 378
column: 30
fix: ~

View File

@@ -4,60 +4,52 @@ expression: checks
---
- kind: EndsInPunctuation
location:
row: 350
row: 355
column: 4
end_location:
row: 350
row: 355
column: 17
fix: ~
- kind: EndsInPunctuation
location:
row: 401
row: 406
column: 24
end_location:
row: 401
row: 406
column: 39
fix: ~
- kind: EndsInPunctuation
location:
row: 405
row: 410
column: 4
end_location:
row: 405
row: 410
column: 24
fix: ~
- kind: EndsInPunctuation
location:
row: 411
row: 416
column: 4
end_location:
row: 411
row: 416
column: 24
fix: ~
- kind: EndsInPunctuation
location:
row: 417
row: 422
column: 34
end_location:
row: 417
row: 422
column: 49
fix: ~
- kind: EndsInPunctuation
location:
row: 424
row: 429
column: 48
end_location:
row: 424
row: 429
column: 63
fix: ~
- kind: EndsInPunctuation
location:
row: 465
column: 4
end_location:
row: 465
column: 24
fix: ~
- kind: EndsInPunctuation
location:
row: 470
@@ -76,26 +68,34 @@ expression: checks
fix: ~
- kind: EndsInPunctuation
location:
row: 482
row: 480
column: 4
end_location:
row: 482
row: 480
column: 24
fix: ~
- kind: EndsInPunctuation
location:
row: 504
row: 487
column: 4
end_location:
row: 504
row: 487
column: 24
fix: ~
- kind: EndsInPunctuation
location:
row: 509
column: 4
end_location:
row: 509
column: 34
fix: ~
- kind: EndsInPunctuation
location:
row: 515
row: 520
column: 4
end_location:
row: 515
row: 520
column: 32
fix: ~

View File

@@ -4,26 +4,26 @@ expression: checks
---
- kind: SkipDocstring
location:
row: 33
row: 34
column: 4
end_location:
row: 37
row: 38
column: 4
fix: ~
- kind: SkipDocstring
location:
row: 85
row: 90
column: 4
end_location:
row: 89
row: 94
column: 4
fix: ~
- kind: SkipDocstring
location:
row: 105
row: 110
column: 0
end_location:
row: 110
row: 115
column: 0
fix: ~

View File

@@ -4,26 +4,26 @@ expression: checks
---
- kind: NonEmpty
location:
row: 19
row: 20
column: 8
end_location:
row: 19
row: 20
column: 14
fix: ~
- kind: NonEmpty
location:
row: 69
row: 74
column: 4
end_location:
row: 69
row: 74
column: 11
fix: ~
- kind: NonEmpty
location:
row: 75
row: 80
column: 8
end_location:
row: 75
row: 80
column: 10
fix: ~

View File

@@ -4,10 +4,26 @@ expression: checks
---
- kind: BooleanPositionalValueInFunctionCall
location:
row: 41
row: 42
column: 10
end_location:
row: 41
row: 42
column: 14
fix: ~
- kind: BooleanPositionalValueInFunctionCall
location:
row: 57
column: 10
end_location:
row: 57
column: 14
fix: ~
- kind: BooleanPositionalValueInFunctionCall
location:
row: 57
column: 16
end_location:
row: 57
column: 21
fix: ~

View File

@@ -60,6 +60,17 @@ pub fn is_overload(stmt: &Stmt) -> bool {
}
}
/// Returns `true` if a function definition is an `@override` (PEP 698).
pub fn is_override(stmt: &Stmt) -> bool {
match &stmt.node {
StmtKind::FunctionDef { decorator_list, .. }
| StmtKind::AsyncFunctionDef { decorator_list, .. } => decorator_list
.iter()
.any(|expr| match_name_or_attr(expr, "override")),
_ => panic!("Found non-FunctionDef in is_override"),
}
}
/// Returns `true` if a function is a "magic method".
pub fn is_magic(stmt: &Stmt) -> bool {
match &stmt.node {