mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
Pretty print Diagnostic
s in snapshot tests (#3906)
This commit is contained in:
parent
210083bdd8
commit
e8aebee3f6
901 changed files with 55367 additions and 66782 deletions
119
Cargo.lock
generated
119
Cargo.lock
generated
|
@ -153,15 +153,6 @@ version = "1.3.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bstr"
|
||||
version = "0.2.17"
|
||||
|
@ -446,15 +437,6 @@ version = "0.8.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.3.2"
|
||||
|
@ -549,16 +531,6 @@ version = "0.2.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctor"
|
||||
version = "0.1.26"
|
||||
|
@ -625,16 +597,6 @@ version = "0.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"crypto-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "4.0.0"
|
||||
|
@ -825,16 +787,6 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.8"
|
||||
|
@ -1018,9 +970,6 @@ dependencies = [
|
|||
"console",
|
||||
"lazy_static",
|
||||
"linked-hash-map",
|
||||
"pest",
|
||||
"pest_derive",
|
||||
"serde",
|
||||
"similar",
|
||||
"yaml-rust",
|
||||
]
|
||||
|
@ -1560,50 +1509,6 @@ version = "2.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
|
||||
|
||||
[[package]]
|
||||
name = "pest"
|
||||
version = "2.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "028accff104c4e513bad663bbcd2ad7cfd5304144404c31ed0a77ac103d00660"
|
||||
dependencies = [
|
||||
"thiserror",
|
||||
"ucd-trie",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_derive"
|
||||
version = "2.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ac3922aac69a40733080f53c1ce7f91dcf57e1a5f6c52f421fadec7fbdc4b69"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_generator",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_generator"
|
||||
version = "2.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d06646e185566b5961b4058dd107e0a7f56e77c3f484549fb119867773c0f202"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_meta",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_meta"
|
||||
version = "2.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6f60b2ba541577e2a0c307c8f39d1439108120eb7903adeb6497fa880c59616"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"pest",
|
||||
"sha2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "petgraph"
|
||||
version = "0.6.3"
|
||||
|
@ -2024,6 +1929,7 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_json",
|
||||
"shellexpand",
|
||||
"similar",
|
||||
"smallvec",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
|
@ -2546,17 +2452,6 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shellexpand"
|
||||
version = "3.0.0"
|
||||
|
@ -2939,18 +2834,6 @@ version = "2.0.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a"
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
|
||||
|
||||
[[package]]
|
||||
name = "ucd-trie"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81"
|
||||
|
||||
[[package]]
|
||||
name = "unic-char-property"
|
||||
version = "0.9.0"
|
||||
|
|
|
@ -60,6 +60,7 @@ schemars = { workspace = true }
|
|||
semver = { version = "1.0.16" }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
similar = { workspace = true, features = ["inline"] }
|
||||
shellexpand = { workspace = true }
|
||||
smallvec = { workspace = true }
|
||||
strum = { workspace = true }
|
||||
|
@ -71,7 +72,7 @@ typed-arena = { version = "2.0.2" }
|
|||
unicode-width = { version = "0.1.10" }
|
||||
|
||||
[dev-dependencies]
|
||||
insta = { workspace = true, features = ["yaml", "redactions"] }
|
||||
insta = { workspace = true }
|
||||
pretty_assertions = "1.3.0"
|
||||
test-case = { workspace = true }
|
||||
# Disable colored output in tests
|
||||
|
|
194
crates/ruff/src/message/diff.rs
Normal file
194
crates/ruff/src/message/diff.rs
Normal file
|
@ -0,0 +1,194 @@
|
|||
use crate::message::Message;
|
||||
use colored::{Color, ColoredString, Colorize, Styles};
|
||||
use ruff_diagnostics::Fix;
|
||||
use ruff_python_ast::source_code::{OneIndexed, SourceCode};
|
||||
use ruff_python_ast::types::Range;
|
||||
use ruff_text_size::{TextRange, TextSize};
|
||||
use similar::{ChangeTag, TextDiff};
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::num::NonZeroUsize;
|
||||
|
||||
/// Renders a diff that shows the code fixes.
|
||||
///
|
||||
/// The implementation isn't fully fledged out and only used by tests. Before using in production, try
|
||||
/// * Improve layout
|
||||
/// * Replace tabs with spaces for a consistent experience across terminals
|
||||
/// * Replace zero-width whitespaces
|
||||
/// * Print a simpler diff if only a single line has changed
|
||||
/// * Compute the diff from the [`Edit`] because diff calculation is expensive.
|
||||
pub(super) struct Diff<'a> {
|
||||
fix: &'a Fix,
|
||||
source_code: SourceCode<'a, 'a>,
|
||||
}
|
||||
|
||||
impl<'a> Diff<'a> {
|
||||
pub fn from_message(message: &'a Message) -> Option<Diff> {
|
||||
match message.file.source_code() {
|
||||
Some(source_code) if !message.fix.is_empty() => Some(Diff {
|
||||
source_code,
|
||||
fix: &message.fix,
|
||||
}),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Diff<'_> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
let mut output = String::with_capacity(self.source_code.text().len());
|
||||
let mut last_end = TextSize::default();
|
||||
|
||||
for edit in self.fix.edits() {
|
||||
let edit_range = self
|
||||
.source_code
|
||||
.text_range(Range::new(edit.location(), edit.end_location()));
|
||||
output.push_str(&self.source_code.text()[TextRange::new(last_end, edit_range.start())]);
|
||||
output.push_str(edit.content().unwrap_or_default());
|
||||
last_end = edit_range.end();
|
||||
}
|
||||
|
||||
output.push_str(&self.source_code.text()[usize::from(last_end)..]);
|
||||
|
||||
let diff = TextDiff::from_lines(self.source_code.text(), &output);
|
||||
|
||||
writeln!(f, "{}", "ℹ Suggested fix".blue())?;
|
||||
|
||||
let (largest_old, largest_new) = diff
|
||||
.ops()
|
||||
.last()
|
||||
.map(|op| (op.old_range().start, op.new_range().start))
|
||||
.unwrap_or_default();
|
||||
|
||||
let digit_with =
|
||||
calculate_print_width(OneIndexed::from_zero_indexed(largest_new.max(largest_old)));
|
||||
|
||||
for (idx, group) in diff.grouped_ops(3).iter().enumerate() {
|
||||
if idx > 0 {
|
||||
writeln!(f, "{:-^1$}", "-", 80)?;
|
||||
}
|
||||
for op in group {
|
||||
for change in diff.iter_inline_changes(op) {
|
||||
let sign = match change.tag() {
|
||||
ChangeTag::Delete => "-",
|
||||
ChangeTag::Insert => "+",
|
||||
ChangeTag::Equal => " ",
|
||||
};
|
||||
|
||||
let line_style = LineStyle::from(change.tag());
|
||||
|
||||
let old_index = change.old_index().map(OneIndexed::from_zero_indexed);
|
||||
let new_index = change.new_index().map(OneIndexed::from_zero_indexed);
|
||||
|
||||
write!(
|
||||
f,
|
||||
"{} {} |{}",
|
||||
Line {
|
||||
index: old_index,
|
||||
width: digit_with
|
||||
},
|
||||
Line {
|
||||
index: new_index,
|
||||
width: digit_with
|
||||
},
|
||||
line_style.apply_to(sign).bold()
|
||||
)?;
|
||||
|
||||
for (emphasized, value) in change.iter_strings_lossy() {
|
||||
if emphasized {
|
||||
write!(f, "{}", line_style.apply_to(&value).underline().on_black())?;
|
||||
} else {
|
||||
write!(f, "{}", line_style.apply_to(&value))?;
|
||||
}
|
||||
}
|
||||
if change.missing_newline() {
|
||||
writeln!(f)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
struct LineStyle {
|
||||
fgcolor: Option<Color>,
|
||||
style: Option<Styles>,
|
||||
}
|
||||
|
||||
impl LineStyle {
|
||||
fn apply_to(&self, input: &str) -> ColoredString {
|
||||
let mut colored = ColoredString::from(input);
|
||||
if let Some(color) = self.fgcolor {
|
||||
colored = colored.color(color);
|
||||
}
|
||||
|
||||
if let Some(style) = self.style {
|
||||
match style {
|
||||
Styles::Clear => colored.clear(),
|
||||
Styles::Bold => colored.bold(),
|
||||
Styles::Dimmed => colored.dimmed(),
|
||||
Styles::Underline => colored.underline(),
|
||||
Styles::Reversed => colored.reversed(),
|
||||
Styles::Italic => colored.italic(),
|
||||
Styles::Blink => colored.blink(),
|
||||
Styles::Hidden => colored.hidden(),
|
||||
Styles::Strikethrough => colored.strikethrough(),
|
||||
}
|
||||
} else {
|
||||
colored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ChangeTag> for LineStyle {
|
||||
fn from(value: ChangeTag) -> Self {
|
||||
match value {
|
||||
ChangeTag::Equal => LineStyle {
|
||||
fgcolor: None,
|
||||
style: Some(Styles::Dimmed),
|
||||
},
|
||||
ChangeTag::Delete => LineStyle {
|
||||
fgcolor: Some(Color::Red),
|
||||
style: None,
|
||||
},
|
||||
ChangeTag::Insert => LineStyle {
|
||||
fgcolor: Some(Color::Green),
|
||||
style: None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Line {
|
||||
index: Option<OneIndexed>,
|
||||
width: NonZeroUsize,
|
||||
}
|
||||
|
||||
impl Display for Line {
|
||||
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
|
||||
match self.index {
|
||||
None => {
|
||||
for _ in 0..self.width.get() {
|
||||
f.write_str(" ")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Some(idx) => write!(f, "{:<width$}", idx, width = self.width.get()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculate the length of the string representation of `value`
|
||||
pub(super) fn calculate_print_width(mut value: OneIndexed) -> NonZeroUsize {
|
||||
const TEN: OneIndexed = OneIndexed::from_zero_indexed(9);
|
||||
|
||||
let mut width = OneIndexed::ONE;
|
||||
|
||||
while value >= TEN {
|
||||
value = OneIndexed::new(value.get() / 10).unwrap_or(OneIndexed::MIN);
|
||||
width = width.checked_add(1).unwrap();
|
||||
}
|
||||
|
||||
width
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
mod azure;
|
||||
mod diff;
|
||||
mod github;
|
||||
mod gitlab;
|
||||
mod grouped;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::fs::relativize_path;
|
||||
use crate::message::diff::Diff;
|
||||
use crate::message::{Emitter, EmitterContext, Message};
|
||||
use crate::registry::AsRule;
|
||||
use annotate_snippets::display_list::{DisplayList, FormatOptions};
|
||||
|
@ -14,6 +15,7 @@ use std::io::Write;
|
|||
#[derive(Default)]
|
||||
pub struct TextEmitter {
|
||||
show_fix_status: bool,
|
||||
show_fix: bool,
|
||||
}
|
||||
|
||||
impl TextEmitter {
|
||||
|
@ -22,6 +24,12 @@ impl TextEmitter {
|
|||
self.show_fix_status = show_fix_status;
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_show_fix(mut self, show_fix: bool) -> Self {
|
||||
self.show_fix = show_fix;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Emitter for TextEmitter {
|
||||
|
@ -69,6 +77,12 @@ impl Emitter for TextEmitter {
|
|||
|
||||
if message.file.source_code().is_some() {
|
||||
writeln!(writer, "{}", MessageCodeFrame { message })?;
|
||||
|
||||
if self.show_fix {
|
||||
if let Some(diff) = Diff::from_message(message) {
|
||||
writeln!(writer, "{diff}")?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ mod tests {
|
|||
use std::path::Path;
|
||||
|
||||
use anyhow::Result;
|
||||
use insta::assert_yaml_snapshot;
|
||||
|
||||
use test_case::test_case;
|
||||
|
||||
use crate::registry::Rule;
|
||||
use crate::settings;
|
||||
use crate::test::test_path;
|
||||
use crate::{assert_messages, settings};
|
||||
|
||||
#[test_case(Rule::CommentedOutCode, Path::new("ERA001.py"); "ERA001")]
|
||||
fn rules(rule_code: Rule, path: &Path) -> Result<()> {
|
||||
|
@ -21,7 +21,7 @@ mod tests {
|
|||
Path::new("eradicate").join(path).as_path(),
|
||||
&settings::Settings::for_rule(rule_code),
|
||||
)?;
|
||||
assert_yaml_snapshot!(snapshot, diagnostics);
|
||||
assert_messages!(snapshot, diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,110 +1,93 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/eradicate/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: CommentedOutCode
|
||||
body: Found commented-out code
|
||||
suggestion: Remove commented-out code
|
||||
fixable: true
|
||||
location:
|
||||
row: 1
|
||||
column: 0
|
||||
end_location:
|
||||
row: 1
|
||||
column: 10
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 1
|
||||
column: 0
|
||||
end_location:
|
||||
row: 2
|
||||
column: 0
|
||||
content: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
name: CommentedOutCode
|
||||
body: Found commented-out code
|
||||
suggestion: Remove commented-out code
|
||||
fixable: true
|
||||
location:
|
||||
row: 2
|
||||
column: 0
|
||||
end_location:
|
||||
row: 2
|
||||
column: 22
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 2
|
||||
column: 0
|
||||
end_location:
|
||||
row: 3
|
||||
column: 0
|
||||
content: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
name: CommentedOutCode
|
||||
body: Found commented-out code
|
||||
suggestion: Remove commented-out code
|
||||
fixable: true
|
||||
location:
|
||||
row: 3
|
||||
column: 0
|
||||
end_location:
|
||||
row: 3
|
||||
column: 6
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 3
|
||||
column: 0
|
||||
end_location:
|
||||
row: 4
|
||||
column: 0
|
||||
content: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
name: CommentedOutCode
|
||||
body: Found commented-out code
|
||||
suggestion: Remove commented-out code
|
||||
fixable: true
|
||||
location:
|
||||
row: 5
|
||||
column: 0
|
||||
end_location:
|
||||
row: 5
|
||||
column: 13
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 5
|
||||
column: 0
|
||||
end_location:
|
||||
row: 6
|
||||
column: 0
|
||||
content: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
name: CommentedOutCode
|
||||
body: Found commented-out code
|
||||
suggestion: Remove commented-out code
|
||||
fixable: true
|
||||
location:
|
||||
row: 12
|
||||
column: 4
|
||||
end_location:
|
||||
row: 12
|
||||
column: 16
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 12
|
||||
column: 0
|
||||
end_location:
|
||||
row: 13
|
||||
column: 0
|
||||
content: ~
|
||||
parent: ~
|
||||
./resources/test/fixtures/eradicate/ERA001.py:1:1: ERA001 [*] Found commented-out code
|
||||
|
|
||||
1 | #import os
|
||||
| ^^^^^^^^^^ ERA001
|
||||
2 | # from foo import junk
|
||||
3 | #a = 3
|
||||
|
|
||||
= help: Remove commented-out code
|
||||
|
||||
ℹ Suggested fix
|
||||
1 |-#import os
|
||||
2 1 | # from foo import junk
|
||||
3 2 | #a = 3
|
||||
4 3 | a = 4
|
||||
|
||||
./resources/test/fixtures/eradicate/ERA001.py:2:1: ERA001 [*] Found commented-out code
|
||||
|
|
||||
2 | #import os
|
||||
3 | # from foo import junk
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ ERA001
|
||||
4 | #a = 3
|
||||
5 | a = 4
|
||||
|
|
||||
= help: Remove commented-out code
|
||||
|
||||
ℹ Suggested fix
|
||||
1 1 | #import os
|
||||
2 |-# from foo import junk
|
||||
3 2 | #a = 3
|
||||
4 3 | a = 4
|
||||
5 4 | #foo(1, 2, 3)
|
||||
|
||||
./resources/test/fixtures/eradicate/ERA001.py:3:1: ERA001 [*] Found commented-out code
|
||||
|
|
||||
3 | #import os
|
||||
4 | # from foo import junk
|
||||
5 | #a = 3
|
||||
| ^^^^^^ ERA001
|
||||
6 | a = 4
|
||||
7 | #foo(1, 2, 3)
|
||||
|
|
||||
= help: Remove commented-out code
|
||||
|
||||
ℹ Suggested fix
|
||||
1 1 | #import os
|
||||
2 2 | # from foo import junk
|
||||
3 |-#a = 3
|
||||
4 3 | a = 4
|
||||
5 4 | #foo(1, 2, 3)
|
||||
6 5 |
|
||||
|
||||
./resources/test/fixtures/eradicate/ERA001.py:5:1: ERA001 [*] Found commented-out code
|
||||
|
|
||||
5 | #a = 3
|
||||
6 | a = 4
|
||||
7 | #foo(1, 2, 3)
|
||||
| ^^^^^^^^^^^^^ ERA001
|
||||
8 |
|
||||
9 | def foo(x, y, z):
|
||||
|
|
||||
= help: Remove commented-out code
|
||||
|
||||
ℹ Suggested fix
|
||||
2 2 | # from foo import junk
|
||||
3 3 | #a = 3
|
||||
4 4 | a = 4
|
||||
5 |-#foo(1, 2, 3)
|
||||
6 5 |
|
||||
7 6 | def foo(x, y, z):
|
||||
8 7 | content = 1 # print('hello')
|
||||
|
||||
./resources/test/fixtures/eradicate/ERA001.py:12:5: ERA001 [*] Found commented-out code
|
||||
|
|
||||
12 | # This is a real comment.
|
||||
13 | #return True
|
||||
| ^^^^^^^^^^^^ ERA001
|
||||
14 | return False
|
||||
|
|
||||
= help: Remove commented-out code
|
||||
|
||||
ℹ Suggested fix
|
||||
9 9 | print(x, y, z)
|
||||
10 10 |
|
||||
11 11 | # This is a real comment.
|
||||
12 |- #return True
|
||||
13 12 | return False
|
||||
14 13 |
|
||||
15 14 | #import os # noqa: ERA001
|
||||
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@ mod tests {
|
|||
use std::path::Path;
|
||||
|
||||
use anyhow::Result;
|
||||
use insta::assert_yaml_snapshot;
|
||||
|
||||
use test_case::test_case;
|
||||
|
||||
use crate::registry::Rule;
|
||||
use crate::settings;
|
||||
use crate::test::test_path;
|
||||
use crate::{assert_messages, settings};
|
||||
|
||||
#[test_case(Rule::SysVersionSlice3, Path::new("YTT101.py"); "YTT101")]
|
||||
#[test_case(Rule::SysVersion2, Path::new("YTT102.py"); "YTT102")]
|
||||
|
@ -29,7 +29,7 @@ mod tests {
|
|||
Path::new("flake8_2020").join(path).as_path(),
|
||||
&settings::Settings::for_rule(rule_code),
|
||||
)?;
|
||||
assert_yaml_snapshot!(snapshot, diagnostics);
|
||||
assert_messages!(snapshot, diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,47 +1,32 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_2020/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: SysVersionSlice3
|
||||
body: "`sys.version[:3]` referenced (python3.10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 6
|
||||
column: 6
|
||||
end_location:
|
||||
row: 6
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SysVersionSlice3
|
||||
body: "`sys.version[:3]` referenced (python3.10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 7
|
||||
column: 6
|
||||
end_location:
|
||||
row: 7
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SysVersionSlice3
|
||||
body: "`sys.version[:3]` referenced (python3.10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 6
|
||||
end_location:
|
||||
row: 8
|
||||
column: 7
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_2020/YTT101.py:6:7: YTT101 `sys.version[:3]` referenced (python3.10), use `sys.version_info`
|
||||
|
|
||||
6 | print(sys.version)
|
||||
7 |
|
||||
8 | print(sys.version[:3])
|
||||
| ^^^^^^^^^^^ YTT101
|
||||
9 | print(version[:3])
|
||||
10 | print(v[:3])
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT101.py:7:7: YTT101 `sys.version[:3]` referenced (python3.10), use `sys.version_info`
|
||||
|
|
||||
7 | print(sys.version[:3])
|
||||
8 | print(version[:3])
|
||||
| ^^^^^^^ YTT101
|
||||
9 | print(v[:3])
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT101.py:8:7: YTT101 `sys.version[:3]` referenced (python3.10), use `sys.version_info`
|
||||
|
|
||||
8 | print(sys.version[:3])
|
||||
9 | print(version[:3])
|
||||
10 | print(v[:3])
|
||||
| ^ YTT101
|
||||
11 |
|
||||
12 | # the tool is timid and only flags certain numeric slices
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,33 +1,20 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_2020/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: SysVersion2
|
||||
body: "`sys.version[2]` referenced (python3.10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 11
|
||||
end_location:
|
||||
row: 4
|
||||
column: 22
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SysVersion2
|
||||
body: "`sys.version[2]` referenced (python3.10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 11
|
||||
end_location:
|
||||
row: 5
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_2020/YTT102.py:4:12: YTT102 `sys.version[2]` referenced (python3.10), use `sys.version_info`
|
||||
|
|
||||
4 | from sys import version
|
||||
5 |
|
||||
6 | py_minor = sys.version[2]
|
||||
| ^^^^^^^^^^^ YTT102
|
||||
7 | py_minor = version[2]
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT102.py:5:12: YTT102 `sys.version[2]` referenced (python3.10), use `sys.version_info`
|
||||
|
|
||||
5 | py_minor = sys.version[2]
|
||||
6 | py_minor = version[2]
|
||||
| ^^^^^^^ YTT102
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,75 +1,50 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_2020/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: SysVersionCmpStr3
|
||||
body: "`sys.version` compared to string (python3.10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 0
|
||||
end_location:
|
||||
row: 4
|
||||
column: 7
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SysVersionCmpStr3
|
||||
body: "`sys.version` compared to string (python3.10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 0
|
||||
end_location:
|
||||
row: 5
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SysVersionCmpStr3
|
||||
body: "`sys.version` compared to string (python3.10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 6
|
||||
column: 0
|
||||
end_location:
|
||||
row: 6
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SysVersionCmpStr3
|
||||
body: "`sys.version` compared to string (python3.10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 7
|
||||
column: 0
|
||||
end_location:
|
||||
row: 7
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SysVersionCmpStr3
|
||||
body: "`sys.version` compared to string (python3.10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 0
|
||||
end_location:
|
||||
row: 8
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_2020/YTT103.py:4:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info`
|
||||
|
|
||||
4 | from sys import version
|
||||
5 |
|
||||
6 | version < "3.5"
|
||||
| ^^^^^^^ YTT103
|
||||
7 | sys.version < "3.5"
|
||||
8 | sys.version <= "3.5"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT103.py:5:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info`
|
||||
|
|
||||
5 | version < "3.5"
|
||||
6 | sys.version < "3.5"
|
||||
| ^^^^^^^^^^^ YTT103
|
||||
7 | sys.version <= "3.5"
|
||||
8 | sys.version > "3.5"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT103.py:6:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info`
|
||||
|
|
||||
6 | version < "3.5"
|
||||
7 | sys.version < "3.5"
|
||||
8 | sys.version <= "3.5"
|
||||
| ^^^^^^^^^^^ YTT103
|
||||
9 | sys.version > "3.5"
|
||||
10 | sys.version >= "3.5"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT103.py:7:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info`
|
||||
|
|
||||
7 | sys.version < "3.5"
|
||||
8 | sys.version <= "3.5"
|
||||
9 | sys.version > "3.5"
|
||||
| ^^^^^^^^^^^ YTT103
|
||||
10 | sys.version >= "3.5"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT103.py:8:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info`
|
||||
|
|
||||
8 | sys.version <= "3.5"
|
||||
9 | sys.version > "3.5"
|
||||
10 | sys.version >= "3.5"
|
||||
| ^^^^^^^^^^^ YTT103
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,61 +1,40 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_2020/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: SysVersionInfo0Eq3
|
||||
body: "`sys.version_info[0] == 3` referenced (python4), use `>=`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 7
|
||||
column: 6
|
||||
end_location:
|
||||
row: 7
|
||||
column: 25
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SysVersionInfo0Eq3
|
||||
body: "`sys.version_info[0] == 3` referenced (python4), use `>=`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 6
|
||||
end_location:
|
||||
row: 8
|
||||
column: 21
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SysVersionInfo0Eq3
|
||||
body: "`sys.version_info[0] == 3` referenced (python4), use `>=`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 9
|
||||
column: 6
|
||||
end_location:
|
||||
row: 9
|
||||
column: 25
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SysVersionInfo0Eq3
|
||||
body: "`sys.version_info[0] == 3` referenced (python4), use `>=`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 10
|
||||
column: 6
|
||||
end_location:
|
||||
row: 10
|
||||
column: 21
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_2020/YTT201.py:7:7: YTT201 `sys.version_info[0] == 3` referenced (python4), use `>=`
|
||||
|
|
||||
7 | PY3 = sys.version_info[0] >= 3
|
||||
8 |
|
||||
9 | PY3 = sys.version_info[0] == 3
|
||||
| ^^^^^^^^^^^^^^^^^^^ YTT201
|
||||
10 | PY3 = version_info[0] == 3
|
||||
11 | PY2 = sys.version_info[0] != 3
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT201.py:8:7: YTT201 `sys.version_info[0] == 3` referenced (python4), use `>=`
|
||||
|
|
||||
8 | PY3 = sys.version_info[0] == 3
|
||||
9 | PY3 = version_info[0] == 3
|
||||
| ^^^^^^^^^^^^^^^ YTT201
|
||||
10 | PY2 = sys.version_info[0] != 3
|
||||
11 | PY2 = version_info[0] != 3
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT201.py:9:7: YTT201 `sys.version_info[0] == 3` referenced (python4), use `>=`
|
||||
|
|
||||
9 | PY3 = sys.version_info[0] == 3
|
||||
10 | PY3 = version_info[0] == 3
|
||||
11 | PY2 = sys.version_info[0] != 3
|
||||
| ^^^^^^^^^^^^^^^^^^^ YTT201
|
||||
12 | PY2 = version_info[0] != 3
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT201.py:10:7: YTT201 `sys.version_info[0] == 3` referenced (python4), use `>=`
|
||||
|
|
||||
10 | PY3 = version_info[0] == 3
|
||||
11 | PY2 = sys.version_info[0] != 3
|
||||
12 | PY2 = version_info[0] != 3
|
||||
| ^^^^^^^^^^^^^^^ YTT201
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,33 +1,23 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_2020/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: SixPY3
|
||||
body: "`six.PY3` referenced (python4), use `not six.PY2`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 3
|
||||
end_location:
|
||||
row: 4
|
||||
column: 10
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SixPY3
|
||||
body: "`six.PY3` referenced (python4), use `not six.PY2`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 6
|
||||
column: 3
|
||||
end_location:
|
||||
row: 6
|
||||
column: 6
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_2020/YTT202.py:4:4: YTT202 `six.PY3` referenced (python4), use `not six.PY2`
|
||||
|
|
||||
4 | from six import PY3
|
||||
5 |
|
||||
6 | if six.PY3:
|
||||
| ^^^^^^^ YTT202
|
||||
7 | print("3")
|
||||
8 | if PY3:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT202.py:6:4: YTT202 `six.PY3` referenced (python4), use `not six.PY2`
|
||||
|
|
||||
6 | if six.PY3:
|
||||
7 | print("3")
|
||||
8 | if PY3:
|
||||
| ^^^ YTT202
|
||||
9 | print("3")
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,33 +1,20 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_2020/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: SysVersionInfo1CmpInt
|
||||
body: "`sys.version_info[1]` compared to integer (python4), compare `sys.version_info` to tuple"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 0
|
||||
end_location:
|
||||
row: 4
|
||||
column: 19
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SysVersionInfo1CmpInt
|
||||
body: "`sys.version_info[1]` compared to integer (python4), compare `sys.version_info` to tuple"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 0
|
||||
end_location:
|
||||
row: 5
|
||||
column: 15
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_2020/YTT203.py:4:1: YTT203 `sys.version_info[1]` compared to integer (python4), compare `sys.version_info` to tuple
|
||||
|
|
||||
4 | from sys import version_info
|
||||
5 |
|
||||
6 | sys.version_info[1] >= 5
|
||||
| ^^^^^^^^^^^^^^^^^^^ YTT203
|
||||
7 | version_info[1] < 6
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT203.py:5:1: YTT203 `sys.version_info[1]` compared to integer (python4), compare `sys.version_info` to tuple
|
||||
|
|
||||
5 | sys.version_info[1] >= 5
|
||||
6 | version_info[1] < 6
|
||||
| ^^^^^^^^^^^^^^^ YTT203
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,33 +1,20 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_2020/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: SysVersionInfoMinorCmpInt
|
||||
body: "`sys.version_info.minor` compared to integer (python4), compare `sys.version_info` to tuple"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 0
|
||||
end_location:
|
||||
row: 4
|
||||
column: 22
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SysVersionInfoMinorCmpInt
|
||||
body: "`sys.version_info.minor` compared to integer (python4), compare `sys.version_info` to tuple"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 0
|
||||
end_location:
|
||||
row: 5
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_2020/YTT204.py:4:1: YTT204 `sys.version_info.minor` compared to integer (python4), compare `sys.version_info` to tuple
|
||||
|
|
||||
4 | from sys import version_info
|
||||
5 |
|
||||
6 | sys.version_info.minor <= 7
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ YTT204
|
||||
7 | version_info.minor > 8
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT204.py:5:1: YTT204 `sys.version_info.minor` compared to integer (python4), compare `sys.version_info` to tuple
|
||||
|
|
||||
5 | sys.version_info.minor <= 7
|
||||
6 | version_info.minor > 8
|
||||
| ^^^^^^^^^^^^^^^^^^ YTT204
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,33 +1,20 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_2020/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: SysVersion0
|
||||
body: "`sys.version[0]` referenced (python10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 11
|
||||
end_location:
|
||||
row: 4
|
||||
column: 22
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SysVersion0
|
||||
body: "`sys.version[0]` referenced (python10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 11
|
||||
end_location:
|
||||
row: 5
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_2020/YTT301.py:4:12: YTT301 `sys.version[0]` referenced (python10), use `sys.version_info`
|
||||
|
|
||||
4 | from sys import version
|
||||
5 |
|
||||
6 | py_major = sys.version[0]
|
||||
| ^^^^^^^^^^^ YTT301
|
||||
7 | py_major = version[0]
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT301.py:5:12: YTT301 `sys.version[0]` referenced (python10), use `sys.version_info`
|
||||
|
|
||||
5 | py_major = sys.version[0]
|
||||
6 | py_major = version[0]
|
||||
| ^^^^^^^ YTT301
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,75 +1,50 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_2020/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: SysVersionCmpStr10
|
||||
body: "`sys.version` compared to string (python10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 0
|
||||
end_location:
|
||||
row: 4
|
||||
column: 7
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SysVersionCmpStr10
|
||||
body: "`sys.version` compared to string (python10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 0
|
||||
end_location:
|
||||
row: 5
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SysVersionCmpStr10
|
||||
body: "`sys.version` compared to string (python10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 6
|
||||
column: 0
|
||||
end_location:
|
||||
row: 6
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SysVersionCmpStr10
|
||||
body: "`sys.version` compared to string (python10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 7
|
||||
column: 0
|
||||
end_location:
|
||||
row: 7
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SysVersionCmpStr10
|
||||
body: "`sys.version` compared to string (python10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 0
|
||||
end_location:
|
||||
row: 8
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_2020/YTT302.py:4:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info`
|
||||
|
|
||||
4 | from sys import version
|
||||
5 |
|
||||
6 | version < "3"
|
||||
| ^^^^^^^ YTT302
|
||||
7 | sys.version < "3"
|
||||
8 | sys.version <= "3"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT302.py:5:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info`
|
||||
|
|
||||
5 | version < "3"
|
||||
6 | sys.version < "3"
|
||||
| ^^^^^^^^^^^ YTT302
|
||||
7 | sys.version <= "3"
|
||||
8 | sys.version > "3"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT302.py:6:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info`
|
||||
|
|
||||
6 | version < "3"
|
||||
7 | sys.version < "3"
|
||||
8 | sys.version <= "3"
|
||||
| ^^^^^^^^^^^ YTT302
|
||||
9 | sys.version > "3"
|
||||
10 | sys.version >= "3"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT302.py:7:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info`
|
||||
|
|
||||
7 | sys.version < "3"
|
||||
8 | sys.version <= "3"
|
||||
9 | sys.version > "3"
|
||||
| ^^^^^^^^^^^ YTT302
|
||||
10 | sys.version >= "3"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT302.py:8:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info`
|
||||
|
|
||||
8 | sys.version <= "3"
|
||||
9 | sys.version > "3"
|
||||
10 | sys.version >= "3"
|
||||
| ^^^^^^^^^^^ YTT302
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,33 +1,20 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_2020/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: SysVersionSlice1
|
||||
body: "`sys.version[:1]` referenced (python10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 6
|
||||
end_location:
|
||||
row: 4
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SysVersionSlice1
|
||||
body: "`sys.version[:1]` referenced (python10), use `sys.version_info`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 6
|
||||
end_location:
|
||||
row: 5
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_2020/YTT303.py:4:7: YTT303 `sys.version[:1]` referenced (python10), use `sys.version_info`
|
||||
|
|
||||
4 | from sys import version
|
||||
5 |
|
||||
6 | print(sys.version[:1])
|
||||
| ^^^^^^^^^^^ YTT303
|
||||
7 | print(version[:1])
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_2020/YTT303.py:5:7: YTT303 `sys.version[:1]` referenced (python10), use `sys.version_info`
|
||||
|
|
||||
5 | print(sys.version[:1])
|
||||
6 | print(version[:1])
|
||||
| ^^^^^^^ YTT303
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ pub mod settings;
|
|||
mod tests {
|
||||
use std::path::Path;
|
||||
|
||||
use crate::assert_messages;
|
||||
use anyhow::Result;
|
||||
use insta::assert_yaml_snapshot;
|
||||
|
||||
use crate::registry::Rule;
|
||||
use crate::settings::Settings;
|
||||
|
@ -35,7 +35,7 @@ mod tests {
|
|||
])
|
||||
},
|
||||
)?;
|
||||
assert_yaml_snapshot!(diagnostics);
|
||||
assert_messages!(diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ mod tests {
|
|||
])
|
||||
},
|
||||
)?;
|
||||
assert_yaml_snapshot!(diagnostics);
|
||||
assert_messages!(diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ mod tests {
|
|||
])
|
||||
},
|
||||
)?;
|
||||
assert_yaml_snapshot!(diagnostics);
|
||||
assert_messages!(diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ mod tests {
|
|||
])
|
||||
},
|
||||
)?;
|
||||
insta::assert_yaml_snapshot!(diagnostics);
|
||||
assert_messages!(diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ mod tests {
|
|||
])
|
||||
},
|
||||
)?;
|
||||
assert_yaml_snapshot!(diagnostics);
|
||||
assert_messages!(diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ mod tests {
|
|||
..Settings::for_rules(vec![Rule::AnyType])
|
||||
},
|
||||
)?;
|
||||
assert_yaml_snapshot!(diagnostics);
|
||||
assert_messages!(diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ mod tests {
|
|||
])
|
||||
},
|
||||
)?;
|
||||
assert_yaml_snapshot!(diagnostics);
|
||||
assert_messages!(diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ mod tests {
|
|||
])
|
||||
},
|
||||
)?;
|
||||
assert_yaml_snapshot!(diagnostics);
|
||||
assert_messages!(diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ mod tests {
|
|||
Path::new("flake8_annotations/simple_magic_methods.py"),
|
||||
&Settings::for_rule(Rule::MissingReturnTypeSpecialMethod),
|
||||
)?;
|
||||
assert_yaml_snapshot!(diagnostics);
|
||||
assert_messages!(diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
---
|
||||
source: src/rules/flake8_annotations/mod.rs
|
||||
expression: diagnostics
|
||||
source: crates/ruff/src/rules/flake8_annotations/mod.rs
|
||||
---
|
||||
[]
|
||||
|
||||
|
|
|
@ -1,19 +1,12 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_annotations/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: MissingReturnTypeUndocumentedPublicFunction
|
||||
body: "Missing return type annotation for public function `bar`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 29
|
||||
column: 8
|
||||
end_location:
|
||||
row: 29
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_annotations/allow_overload.py:29:9: ANN201 Missing return type annotation for public function `bar`
|
||||
|
|
||||
29 | class X:
|
||||
30 | def bar(i):
|
||||
| ^^^ ANN201
|
||||
31 | return i
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,61 +1,36 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_annotations/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: AnyType
|
||||
body: "Dynamically typed expressions (typing.Any) are disallowed in `a`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 10
|
||||
column: 11
|
||||
end_location:
|
||||
row: 10
|
||||
column: 14
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AnyType
|
||||
body: "Dynamically typed expressions (typing.Any) are disallowed in `foo`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 15
|
||||
column: 46
|
||||
end_location:
|
||||
row: 15
|
||||
column: 49
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AnyType
|
||||
body: "Dynamically typed expressions (typing.Any) are disallowed in `a`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 40
|
||||
column: 28
|
||||
end_location:
|
||||
row: 40
|
||||
column: 31
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AnyType
|
||||
body: "Dynamically typed expressions (typing.Any) are disallowed in `foo_method`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 44
|
||||
column: 66
|
||||
end_location:
|
||||
row: 44
|
||||
column: 69
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_annotations/allow_star_arg_any.py:10:12: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a`
|
||||
|
|
||||
10 | # ANN401
|
||||
11 | def foo(a: Any, *args: str, **kwargs: str) -> int:
|
||||
| ^^^ ANN401
|
||||
12 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/allow_star_arg_any.py:15:47: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo`
|
||||
|
|
||||
15 | # ANN401
|
||||
16 | def foo(a: int, *args: str, **kwargs: str) -> Any:
|
||||
| ^^^ ANN401
|
||||
17 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/allow_star_arg_any.py:40:29: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a`
|
||||
|
|
||||
40 | # ANN401
|
||||
41 | def foo_method(self, a: Any, *params: str, **options: str) -> int:
|
||||
| ^^^ ANN401
|
||||
42 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/allow_star_arg_any.py:44:67: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo_method`
|
||||
|
|
||||
44 | # ANN401
|
||||
45 | def foo_method(self, a: int, *params: str, **options: str) -> Any:
|
||||
| ^^^ ANN401
|
||||
46 | pass
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,327 +1,189 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_annotations/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: MissingReturnTypeUndocumentedPublicFunction
|
||||
body: "Missing return type annotation for public function `foo`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 4
|
||||
end_location:
|
||||
row: 4
|
||||
column: 7
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingTypeFunctionArgument
|
||||
body: "Missing type annotation for function argument `a`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 4
|
||||
column: 9
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingTypeFunctionArgument
|
||||
body: "Missing type annotation for function argument `b`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 11
|
||||
end_location:
|
||||
row: 4
|
||||
column: 12
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeUndocumentedPublicFunction
|
||||
body: "Missing return type annotation for public function `foo`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 9
|
||||
column: 4
|
||||
end_location:
|
||||
row: 9
|
||||
column: 7
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingTypeFunctionArgument
|
||||
body: "Missing type annotation for function argument `b`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 9
|
||||
column: 16
|
||||
end_location:
|
||||
row: 9
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingTypeFunctionArgument
|
||||
body: "Missing type annotation for function argument `b`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 14
|
||||
column: 16
|
||||
end_location:
|
||||
row: 14
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeUndocumentedPublicFunction
|
||||
body: "Missing return type annotation for public function `foo`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 19
|
||||
column: 4
|
||||
end_location:
|
||||
row: 19
|
||||
column: 7
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeUndocumentedPublicFunction
|
||||
body: "Missing return type annotation for public function `foo`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 24
|
||||
column: 4
|
||||
end_location:
|
||||
row: 24
|
||||
column: 7
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AnyType
|
||||
body: "Dynamically typed expressions (typing.Any) are disallowed in `a`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 44
|
||||
column: 11
|
||||
end_location:
|
||||
row: 44
|
||||
column: 14
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AnyType
|
||||
body: "Dynamically typed expressions (typing.Any) are disallowed in `foo`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 49
|
||||
column: 46
|
||||
end_location:
|
||||
row: 49
|
||||
column: 49
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AnyType
|
||||
body: "Dynamically typed expressions (typing.Any) are disallowed in `*args`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 54
|
||||
column: 23
|
||||
end_location:
|
||||
row: 54
|
||||
column: 26
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AnyType
|
||||
body: "Dynamically typed expressions (typing.Any) are disallowed in `**kwargs`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 54
|
||||
column: 38
|
||||
end_location:
|
||||
row: 54
|
||||
column: 41
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AnyType
|
||||
body: "Dynamically typed expressions (typing.Any) are disallowed in `*args`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 59
|
||||
column: 23
|
||||
end_location:
|
||||
row: 59
|
||||
column: 26
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AnyType
|
||||
body: "Dynamically typed expressions (typing.Any) are disallowed in `**kwargs`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 64
|
||||
column: 38
|
||||
end_location:
|
||||
row: 64
|
||||
column: 41
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingTypeSelf
|
||||
body: "Missing type annotation for `self` in method"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 74
|
||||
column: 12
|
||||
end_location:
|
||||
row: 74
|
||||
column: 16
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AnyType
|
||||
body: "Dynamically typed expressions (typing.Any) are disallowed in `a`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 78
|
||||
column: 28
|
||||
end_location:
|
||||
row: 78
|
||||
column: 31
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AnyType
|
||||
body: "Dynamically typed expressions (typing.Any) are disallowed in `foo`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 82
|
||||
column: 66
|
||||
end_location:
|
||||
row: 82
|
||||
column: 69
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AnyType
|
||||
body: "Dynamically typed expressions (typing.Any) are disallowed in `*params`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 86
|
||||
column: 42
|
||||
end_location:
|
||||
row: 86
|
||||
column: 45
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AnyType
|
||||
body: "Dynamically typed expressions (typing.Any) are disallowed in `**options`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 86
|
||||
column: 58
|
||||
end_location:
|
||||
row: 86
|
||||
column: 61
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AnyType
|
||||
body: "Dynamically typed expressions (typing.Any) are disallowed in `*params`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 90
|
||||
column: 42
|
||||
end_location:
|
||||
row: 90
|
||||
column: 45
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AnyType
|
||||
body: "Dynamically typed expressions (typing.Any) are disallowed in `**options`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 94
|
||||
column: 58
|
||||
end_location:
|
||||
row: 94
|
||||
column: 61
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingTypeCls
|
||||
body: "Missing type annotation for `cls` in classmethod"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 104
|
||||
column: 12
|
||||
end_location:
|
||||
row: 104
|
||||
column: 15
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingTypeSelf
|
||||
body: "Missing type annotation for `self` in method"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 108
|
||||
column: 12
|
||||
end_location:
|
||||
row: 108
|
||||
column: 16
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:4:5: ANN201 Missing return type annotation for public function `foo`
|
||||
|
|
||||
4 | # Error
|
||||
5 | def foo(a, b):
|
||||
| ^^^ ANN201
|
||||
6 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:4:9: ANN001 Missing type annotation for function argument `a`
|
||||
|
|
||||
4 | # Error
|
||||
5 | def foo(a, b):
|
||||
| ^ ANN001
|
||||
6 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:4:12: ANN001 Missing type annotation for function argument `b`
|
||||
|
|
||||
4 | # Error
|
||||
5 | def foo(a, b):
|
||||
| ^ ANN001
|
||||
6 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:9:5: ANN201 Missing return type annotation for public function `foo`
|
||||
|
|
||||
9 | # Error
|
||||
10 | def foo(a: int, b):
|
||||
| ^^^ ANN201
|
||||
11 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:9:17: ANN001 Missing type annotation for function argument `b`
|
||||
|
|
||||
9 | # Error
|
||||
10 | def foo(a: int, b):
|
||||
| ^ ANN001
|
||||
11 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:14:17: ANN001 Missing type annotation for function argument `b`
|
||||
|
|
||||
14 | # Error
|
||||
15 | def foo(a: int, b) -> int:
|
||||
| ^ ANN001
|
||||
16 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:19:5: ANN201 Missing return type annotation for public function `foo`
|
||||
|
|
||||
19 | # Error
|
||||
20 | def foo(a: int, b: int):
|
||||
| ^^^ ANN201
|
||||
21 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:24:5: ANN201 Missing return type annotation for public function `foo`
|
||||
|
|
||||
24 | # Error
|
||||
25 | def foo():
|
||||
| ^^^ ANN201
|
||||
26 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:44:12: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a`
|
||||
|
|
||||
44 | # ANN401
|
||||
45 | def foo(a: Any, *args: str, **kwargs: str) -> int:
|
||||
| ^^^ ANN401
|
||||
46 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:49:47: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo`
|
||||
|
|
||||
49 | # ANN401
|
||||
50 | def foo(a: int, *args: str, **kwargs: str) -> Any:
|
||||
| ^^^ ANN401
|
||||
51 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:54:24: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*args`
|
||||
|
|
||||
54 | # ANN401
|
||||
55 | def foo(a: int, *args: Any, **kwargs: Any) -> int:
|
||||
| ^^^ ANN401
|
||||
56 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:54:39: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**kwargs`
|
||||
|
|
||||
54 | # ANN401
|
||||
55 | def foo(a: int, *args: Any, **kwargs: Any) -> int:
|
||||
| ^^^ ANN401
|
||||
56 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:59:24: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*args`
|
||||
|
|
||||
59 | # ANN401
|
||||
60 | def foo(a: int, *args: Any, **kwargs: str) -> int:
|
||||
| ^^^ ANN401
|
||||
61 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:64:39: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**kwargs`
|
||||
|
|
||||
64 | # ANN401
|
||||
65 | def foo(a: int, *args: str, **kwargs: Any) -> int:
|
||||
| ^^^ ANN401
|
||||
66 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:74:13: ANN101 Missing type annotation for `self` in method
|
||||
|
|
||||
74 | # ANN101
|
||||
75 | def foo(self, a: int, b: int) -> int:
|
||||
| ^^^^ ANN101
|
||||
76 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:78:29: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a`
|
||||
|
|
||||
78 | # ANN401
|
||||
79 | def foo(self: "Foo", a: Any, *params: str, **options: str) -> int:
|
||||
| ^^^ ANN401
|
||||
80 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:82:67: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo`
|
||||
|
|
||||
82 | # ANN401
|
||||
83 | def foo(self: "Foo", a: int, *params: str, **options: str) -> Any:
|
||||
| ^^^ ANN401
|
||||
84 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:86:43: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*params`
|
||||
|
|
||||
86 | # ANN401
|
||||
87 | def foo(self: "Foo", a: int, *params: Any, **options: Any) -> int:
|
||||
| ^^^ ANN401
|
||||
88 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:86:59: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**options`
|
||||
|
|
||||
86 | # ANN401
|
||||
87 | def foo(self: "Foo", a: int, *params: Any, **options: Any) -> int:
|
||||
| ^^^ ANN401
|
||||
88 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:90:43: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*params`
|
||||
|
|
||||
90 | # ANN401
|
||||
91 | def foo(self: "Foo", a: int, *params: Any, **options: str) -> int:
|
||||
| ^^^ ANN401
|
||||
92 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:94:59: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**options`
|
||||
|
|
||||
94 | # ANN401
|
||||
95 | def foo(self: "Foo", a: int, *params: str, **options: Any) -> int:
|
||||
| ^^^ ANN401
|
||||
96 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:104:13: ANN102 Missing type annotation for `cls` in classmethod
|
||||
|
|
||||
104 | # ANN102
|
||||
105 | @classmethod
|
||||
106 | def foo(cls, a: int, b: int) -> int:
|
||||
| ^^^ ANN102
|
||||
107 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/annotation_presence.py:108:13: ANN101 Missing type annotation for `self` in method
|
||||
|
|
||||
108 | # ANN101
|
||||
109 | def foo(self, /, a: int, b: int) -> int:
|
||||
| ^^^^ ANN101
|
||||
110 | pass
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,75 +1,41 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_annotations/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: MissingReturnTypeUndocumentedPublicFunction
|
||||
body: "Missing return type annotation for public function `error_partially_typed_1`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 24
|
||||
column: 4
|
||||
end_location:
|
||||
row: 24
|
||||
column: 27
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingTypeFunctionArgument
|
||||
body: "Missing type annotation for function argument `b`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 24
|
||||
column: 36
|
||||
end_location:
|
||||
row: 24
|
||||
column: 37
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingTypeFunctionArgument
|
||||
body: "Missing type annotation for function argument `b`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 28
|
||||
column: 36
|
||||
end_location:
|
||||
row: 28
|
||||
column: 37
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeUndocumentedPublicFunction
|
||||
body: "Missing return type annotation for public function `error_partially_typed_3`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 32
|
||||
column: 4
|
||||
end_location:
|
||||
row: 32
|
||||
column: 27
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeUndocumentedPublicFunction
|
||||
body: "Missing return type annotation for public function `error_typed_self`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 43
|
||||
column: 8
|
||||
end_location:
|
||||
row: 43
|
||||
column: 24
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_annotations/ignore_fully_untyped.py:24:5: ANN201 Missing return type annotation for public function `error_partially_typed_1`
|
||||
|
|
||||
24 | def error_partially_typed_1(a: int, b):
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ ANN201
|
||||
25 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/ignore_fully_untyped.py:24:37: ANN001 Missing type annotation for function argument `b`
|
||||
|
|
||||
24 | def error_partially_typed_1(a: int, b):
|
||||
| ^ ANN001
|
||||
25 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/ignore_fully_untyped.py:28:37: ANN001 Missing type annotation for function argument `b`
|
||||
|
|
||||
28 | def error_partially_typed_2(a: int, b) -> int:
|
||||
| ^ ANN001
|
||||
29 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/ignore_fully_untyped.py:32:5: ANN201 Missing return type annotation for public function `error_partially_typed_3`
|
||||
|
|
||||
32 | def error_partially_typed_3(a: int, b: int):
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ ANN201
|
||||
33 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/ignore_fully_untyped.py:43:9: ANN201 Missing return type annotation for public function `error_typed_self`
|
||||
|
|
||||
43 | pass
|
||||
44 |
|
||||
45 | def error_typed_self(self: X):
|
||||
| ^^^^^^^^^^^^^^^^ ANN201
|
||||
46 | pass
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,82 +1,70 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_annotations/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: MissingReturnTypeSpecialMethod
|
||||
body: "Missing return type annotation for special method `__init__`"
|
||||
suggestion: "Add `None` return type"
|
||||
fixable: true
|
||||
location:
|
||||
row: 5
|
||||
column: 8
|
||||
end_location:
|
||||
row: 5
|
||||
column: 16
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 5
|
||||
column: 22
|
||||
end_location:
|
||||
row: 5
|
||||
column: 22
|
||||
content: " -> None"
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeSpecialMethod
|
||||
body: "Missing return type annotation for special method `__init__`"
|
||||
suggestion: "Add `None` return type"
|
||||
fixable: true
|
||||
location:
|
||||
row: 11
|
||||
column: 8
|
||||
end_location:
|
||||
row: 11
|
||||
column: 16
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 11
|
||||
column: 27
|
||||
end_location:
|
||||
row: 11
|
||||
column: 27
|
||||
content: " -> None"
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypePrivateFunction
|
||||
body: "Missing return type annotation for private function `__init__`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 40
|
||||
column: 4
|
||||
end_location:
|
||||
row: 40
|
||||
column: 12
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeSpecialMethod
|
||||
body: "Missing return type annotation for special method `__init__`"
|
||||
suggestion: "Add `None` return type"
|
||||
fixable: true
|
||||
location:
|
||||
row: 47
|
||||
column: 8
|
||||
end_location:
|
||||
row: 47
|
||||
column: 16
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 47
|
||||
column: 28
|
||||
end_location:
|
||||
row: 47
|
||||
column: 28
|
||||
content: " -> None"
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_annotations/mypy_init_return.py:5:9: ANN204 [*] Missing return type annotation for special method `__init__`
|
||||
|
|
||||
5 | # Error
|
||||
6 | class Foo:
|
||||
7 | def __init__(self):
|
||||
| ^^^^^^^^ ANN204
|
||||
8 | ...
|
||||
|
|
||||
= help: Add `None` return type
|
||||
|
||||
ℹ Suggested fix
|
||||
2 2 |
|
||||
3 3 | # Error
|
||||
4 4 | class Foo:
|
||||
5 |- def __init__(self):
|
||||
5 |+ def __init__(self) -> None:
|
||||
6 6 | ...
|
||||
7 7 |
|
||||
8 8 |
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/mypy_init_return.py:11:9: ANN204 [*] Missing return type annotation for special method `__init__`
|
||||
|
|
||||
11 | # Error
|
||||
12 | class Foo:
|
||||
13 | def __init__(self, foo):
|
||||
| ^^^^^^^^ ANN204
|
||||
14 | ...
|
||||
|
|
||||
= help: Add `None` return type
|
||||
|
||||
ℹ Suggested fix
|
||||
8 8 |
|
||||
9 9 | # Error
|
||||
10 10 | class Foo:
|
||||
11 |- def __init__(self, foo):
|
||||
11 |+ def __init__(self, foo) -> None:
|
||||
12 12 | ...
|
||||
13 13 |
|
||||
14 14 |
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/mypy_init_return.py:40:5: ANN202 Missing return type annotation for private function `__init__`
|
||||
|
|
||||
40 | # Error
|
||||
41 | def __init__(self, foo: int):
|
||||
| ^^^^^^^^ ANN202
|
||||
42 | ...
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/mypy_init_return.py:47:9: ANN204 [*] Missing return type annotation for special method `__init__`
|
||||
|
|
||||
47 | # of a vararg falsely indicated that the function has a typed argument.
|
||||
48 | class Foo:
|
||||
49 | def __init__(self, *arg):
|
||||
| ^^^^^^^^ ANN204
|
||||
50 | ...
|
||||
|
|
||||
= help: Add `None` return type
|
||||
|
||||
ℹ Suggested fix
|
||||
44 44 | # Error – used to be ok for a moment since the mere presence
|
||||
45 45 | # of a vararg falsely indicated that the function has a typed argument.
|
||||
46 46 | class Foo:
|
||||
47 |- def __init__(self, *arg):
|
||||
47 |+ def __init__(self, *arg) -> None:
|
||||
48 48 | ...
|
||||
|
||||
|
||||
|
|
|
@ -1,299 +1,279 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_annotations/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: MissingReturnTypeSpecialMethod
|
||||
body: "Missing return type annotation for special method `__str__`"
|
||||
suggestion: "Add `None` return type"
|
||||
fixable: true
|
||||
location:
|
||||
row: 2
|
||||
column: 8
|
||||
end_location:
|
||||
row: 2
|
||||
column: 15
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 2
|
||||
column: 21
|
||||
end_location:
|
||||
row: 2
|
||||
column: 21
|
||||
content: " -> str"
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeSpecialMethod
|
||||
body: "Missing return type annotation for special method `__repr__`"
|
||||
suggestion: "Add `None` return type"
|
||||
fixable: true
|
||||
location:
|
||||
row: 5
|
||||
column: 8
|
||||
end_location:
|
||||
row: 5
|
||||
column: 16
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 5
|
||||
column: 22
|
||||
end_location:
|
||||
row: 5
|
||||
column: 22
|
||||
content: " -> str"
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeSpecialMethod
|
||||
body: "Missing return type annotation for special method `__len__`"
|
||||
suggestion: "Add `None` return type"
|
||||
fixable: true
|
||||
location:
|
||||
row: 8
|
||||
column: 8
|
||||
end_location:
|
||||
row: 8
|
||||
column: 15
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 8
|
||||
column: 21
|
||||
end_location:
|
||||
row: 8
|
||||
column: 21
|
||||
content: " -> int"
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeSpecialMethod
|
||||
body: "Missing return type annotation for special method `__length_hint__`"
|
||||
suggestion: "Add `None` return type"
|
||||
fixable: true
|
||||
location:
|
||||
row: 11
|
||||
column: 8
|
||||
end_location:
|
||||
row: 11
|
||||
column: 23
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 11
|
||||
column: 29
|
||||
end_location:
|
||||
row: 11
|
||||
column: 29
|
||||
content: " -> int"
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeSpecialMethod
|
||||
body: "Missing return type annotation for special method `__init__`"
|
||||
suggestion: "Add `None` return type"
|
||||
fixable: true
|
||||
location:
|
||||
row: 14
|
||||
column: 8
|
||||
end_location:
|
||||
row: 14
|
||||
column: 16
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 14
|
||||
column: 22
|
||||
end_location:
|
||||
row: 14
|
||||
column: 22
|
||||
content: " -> None"
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeSpecialMethod
|
||||
body: "Missing return type annotation for special method `__del__`"
|
||||
suggestion: "Add `None` return type"
|
||||
fixable: true
|
||||
location:
|
||||
row: 17
|
||||
column: 8
|
||||
end_location:
|
||||
row: 17
|
||||
column: 15
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 17
|
||||
column: 21
|
||||
end_location:
|
||||
row: 17
|
||||
column: 21
|
||||
content: " -> None"
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeSpecialMethod
|
||||
body: "Missing return type annotation for special method `__bool__`"
|
||||
suggestion: "Add `None` return type"
|
||||
fixable: true
|
||||
location:
|
||||
row: 20
|
||||
column: 8
|
||||
end_location:
|
||||
row: 20
|
||||
column: 16
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 20
|
||||
column: 22
|
||||
end_location:
|
||||
row: 20
|
||||
column: 22
|
||||
content: " -> bool"
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeSpecialMethod
|
||||
body: "Missing return type annotation for special method `__bytes__`"
|
||||
suggestion: "Add `None` return type"
|
||||
fixable: true
|
||||
location:
|
||||
row: 23
|
||||
column: 8
|
||||
end_location:
|
||||
row: 23
|
||||
column: 17
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 23
|
||||
column: 23
|
||||
end_location:
|
||||
row: 23
|
||||
column: 23
|
||||
content: " -> bytes"
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeSpecialMethod
|
||||
body: "Missing return type annotation for special method `__format__`"
|
||||
suggestion: "Add `None` return type"
|
||||
fixable: true
|
||||
location:
|
||||
row: 26
|
||||
column: 8
|
||||
end_location:
|
||||
row: 26
|
||||
column: 18
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 26
|
||||
column: 37
|
||||
end_location:
|
||||
row: 26
|
||||
column: 37
|
||||
content: " -> str"
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeSpecialMethod
|
||||
body: "Missing return type annotation for special method `__contains__`"
|
||||
suggestion: "Add `None` return type"
|
||||
fixable: true
|
||||
location:
|
||||
row: 29
|
||||
column: 8
|
||||
end_location:
|
||||
row: 29
|
||||
column: 20
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 29
|
||||
column: 32
|
||||
end_location:
|
||||
row: 29
|
||||
column: 32
|
||||
content: " -> bool"
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeSpecialMethod
|
||||
body: "Missing return type annotation for special method `__complex__`"
|
||||
suggestion: "Add `None` return type"
|
||||
fixable: true
|
||||
location:
|
||||
row: 32
|
||||
column: 8
|
||||
end_location:
|
||||
row: 32
|
||||
column: 19
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 32
|
||||
column: 25
|
||||
end_location:
|
||||
row: 32
|
||||
column: 25
|
||||
content: " -> complex"
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeSpecialMethod
|
||||
body: "Missing return type annotation for special method `__int__`"
|
||||
suggestion: "Add `None` return type"
|
||||
fixable: true
|
||||
location:
|
||||
row: 35
|
||||
column: 8
|
||||
end_location:
|
||||
row: 35
|
||||
column: 15
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 35
|
||||
column: 21
|
||||
end_location:
|
||||
row: 35
|
||||
column: 21
|
||||
content: " -> int"
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeSpecialMethod
|
||||
body: "Missing return type annotation for special method `__float__`"
|
||||
suggestion: "Add `None` return type"
|
||||
fixable: true
|
||||
location:
|
||||
row: 38
|
||||
column: 8
|
||||
end_location:
|
||||
row: 38
|
||||
column: 17
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 38
|
||||
column: 23
|
||||
end_location:
|
||||
row: 38
|
||||
column: 23
|
||||
content: " -> float"
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeSpecialMethod
|
||||
body: "Missing return type annotation for special method `__index__`"
|
||||
suggestion: "Add `None` return type"
|
||||
fixable: true
|
||||
location:
|
||||
row: 41
|
||||
column: 8
|
||||
end_location:
|
||||
row: 41
|
||||
column: 17
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 41
|
||||
column: 23
|
||||
end_location:
|
||||
row: 41
|
||||
column: 23
|
||||
content: " -> int"
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_annotations/simple_magic_methods.py:2:9: ANN204 [*] Missing return type annotation for special method `__str__`
|
||||
|
|
||||
2 | class Foo:
|
||||
3 | def __str__(self):
|
||||
| ^^^^^^^ ANN204
|
||||
4 | ...
|
||||
|
|
||||
= help: Add `None` return type
|
||||
|
||||
ℹ Suggested fix
|
||||
1 1 | class Foo:
|
||||
2 |- def __str__(self):
|
||||
2 |+ def __str__(self) -> str:
|
||||
3 3 | ...
|
||||
4 4 |
|
||||
5 5 | def __repr__(self):
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/simple_magic_methods.py:5:9: ANN204 [*] Missing return type annotation for special method `__repr__`
|
||||
|
|
||||
5 | ...
|
||||
6 |
|
||||
7 | def __repr__(self):
|
||||
| ^^^^^^^^ ANN204
|
||||
8 | ...
|
||||
|
|
||||
= help: Add `None` return type
|
||||
|
||||
ℹ Suggested fix
|
||||
2 2 | def __str__(self):
|
||||
3 3 | ...
|
||||
4 4 |
|
||||
5 |- def __repr__(self):
|
||||
5 |+ def __repr__(self) -> str:
|
||||
6 6 | ...
|
||||
7 7 |
|
||||
8 8 | def __len__(self):
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/simple_magic_methods.py:8:9: ANN204 [*] Missing return type annotation for special method `__len__`
|
||||
|
|
||||
8 | ...
|
||||
9 |
|
||||
10 | def __len__(self):
|
||||
| ^^^^^^^ ANN204
|
||||
11 | ...
|
||||
|
|
||||
= help: Add `None` return type
|
||||
|
||||
ℹ Suggested fix
|
||||
5 5 | def __repr__(self):
|
||||
6 6 | ...
|
||||
7 7 |
|
||||
8 |- def __len__(self):
|
||||
8 |+ def __len__(self) -> int:
|
||||
9 9 | ...
|
||||
10 10 |
|
||||
11 11 | def __length_hint__(self):
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/simple_magic_methods.py:11:9: ANN204 [*] Missing return type annotation for special method `__length_hint__`
|
||||
|
|
||||
11 | ...
|
||||
12 |
|
||||
13 | def __length_hint__(self):
|
||||
| ^^^^^^^^^^^^^^^ ANN204
|
||||
14 | ...
|
||||
|
|
||||
= help: Add `None` return type
|
||||
|
||||
ℹ Suggested fix
|
||||
8 8 | def __len__(self):
|
||||
9 9 | ...
|
||||
10 10 |
|
||||
11 |- def __length_hint__(self):
|
||||
11 |+ def __length_hint__(self) -> int:
|
||||
12 12 | ...
|
||||
13 13 |
|
||||
14 14 | def __init__(self):
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/simple_magic_methods.py:14:9: ANN204 [*] Missing return type annotation for special method `__init__`
|
||||
|
|
||||
14 | ...
|
||||
15 |
|
||||
16 | def __init__(self):
|
||||
| ^^^^^^^^ ANN204
|
||||
17 | ...
|
||||
|
|
||||
= help: Add `None` return type
|
||||
|
||||
ℹ Suggested fix
|
||||
11 11 | def __length_hint__(self):
|
||||
12 12 | ...
|
||||
13 13 |
|
||||
14 |- def __init__(self):
|
||||
14 |+ def __init__(self) -> None:
|
||||
15 15 | ...
|
||||
16 16 |
|
||||
17 17 | def __del__(self):
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/simple_magic_methods.py:17:9: ANN204 [*] Missing return type annotation for special method `__del__`
|
||||
|
|
||||
17 | ...
|
||||
18 |
|
||||
19 | def __del__(self):
|
||||
| ^^^^^^^ ANN204
|
||||
20 | ...
|
||||
|
|
||||
= help: Add `None` return type
|
||||
|
||||
ℹ Suggested fix
|
||||
14 14 | def __init__(self):
|
||||
15 15 | ...
|
||||
16 16 |
|
||||
17 |- def __del__(self):
|
||||
17 |+ def __del__(self) -> None:
|
||||
18 18 | ...
|
||||
19 19 |
|
||||
20 20 | def __bool__(self):
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/simple_magic_methods.py:20:9: ANN204 [*] Missing return type annotation for special method `__bool__`
|
||||
|
|
||||
20 | ...
|
||||
21 |
|
||||
22 | def __bool__(self):
|
||||
| ^^^^^^^^ ANN204
|
||||
23 | ...
|
||||
|
|
||||
= help: Add `None` return type
|
||||
|
||||
ℹ Suggested fix
|
||||
17 17 | def __del__(self):
|
||||
18 18 | ...
|
||||
19 19 |
|
||||
20 |- def __bool__(self):
|
||||
20 |+ def __bool__(self) -> bool:
|
||||
21 21 | ...
|
||||
22 22 |
|
||||
23 23 | def __bytes__(self):
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/simple_magic_methods.py:23:9: ANN204 [*] Missing return type annotation for special method `__bytes__`
|
||||
|
|
||||
23 | ...
|
||||
24 |
|
||||
25 | def __bytes__(self):
|
||||
| ^^^^^^^^^ ANN204
|
||||
26 | ...
|
||||
|
|
||||
= help: Add `None` return type
|
||||
|
||||
ℹ Suggested fix
|
||||
20 20 | def __bool__(self):
|
||||
21 21 | ...
|
||||
22 22 |
|
||||
23 |- def __bytes__(self):
|
||||
23 |+ def __bytes__(self) -> bytes:
|
||||
24 24 | ...
|
||||
25 25 |
|
||||
26 26 | def __format__(self, format_spec):
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/simple_magic_methods.py:26:9: ANN204 [*] Missing return type annotation for special method `__format__`
|
||||
|
|
||||
26 | ...
|
||||
27 |
|
||||
28 | def __format__(self, format_spec):
|
||||
| ^^^^^^^^^^ ANN204
|
||||
29 | ...
|
||||
|
|
||||
= help: Add `None` return type
|
||||
|
||||
ℹ Suggested fix
|
||||
23 23 | def __bytes__(self):
|
||||
24 24 | ...
|
||||
25 25 |
|
||||
26 |- def __format__(self, format_spec):
|
||||
26 |+ def __format__(self, format_spec) -> str:
|
||||
27 27 | ...
|
||||
28 28 |
|
||||
29 29 | def __contains__(self, item):
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/simple_magic_methods.py:29:9: ANN204 [*] Missing return type annotation for special method `__contains__`
|
||||
|
|
||||
29 | ...
|
||||
30 |
|
||||
31 | def __contains__(self, item):
|
||||
| ^^^^^^^^^^^^ ANN204
|
||||
32 | ...
|
||||
|
|
||||
= help: Add `None` return type
|
||||
|
||||
ℹ Suggested fix
|
||||
26 26 | def __format__(self, format_spec):
|
||||
27 27 | ...
|
||||
28 28 |
|
||||
29 |- def __contains__(self, item):
|
||||
29 |+ def __contains__(self, item) -> bool:
|
||||
30 30 | ...
|
||||
31 31 |
|
||||
32 32 | def __complex__(self):
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/simple_magic_methods.py:32:9: ANN204 [*] Missing return type annotation for special method `__complex__`
|
||||
|
|
||||
32 | ...
|
||||
33 |
|
||||
34 | def __complex__(self):
|
||||
| ^^^^^^^^^^^ ANN204
|
||||
35 | ...
|
||||
|
|
||||
= help: Add `None` return type
|
||||
|
||||
ℹ Suggested fix
|
||||
29 29 | def __contains__(self, item):
|
||||
30 30 | ...
|
||||
31 31 |
|
||||
32 |- def __complex__(self):
|
||||
32 |+ def __complex__(self) -> complex:
|
||||
33 33 | ...
|
||||
34 34 |
|
||||
35 35 | def __int__(self):
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/simple_magic_methods.py:35:9: ANN204 [*] Missing return type annotation for special method `__int__`
|
||||
|
|
||||
35 | ...
|
||||
36 |
|
||||
37 | def __int__(self):
|
||||
| ^^^^^^^ ANN204
|
||||
38 | ...
|
||||
|
|
||||
= help: Add `None` return type
|
||||
|
||||
ℹ Suggested fix
|
||||
32 32 | def __complex__(self):
|
||||
33 33 | ...
|
||||
34 34 |
|
||||
35 |- def __int__(self):
|
||||
35 |+ def __int__(self) -> int:
|
||||
36 36 | ...
|
||||
37 37 |
|
||||
38 38 | def __float__(self):
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/simple_magic_methods.py:38:9: ANN204 [*] Missing return type annotation for special method `__float__`
|
||||
|
|
||||
38 | ...
|
||||
39 |
|
||||
40 | def __float__(self):
|
||||
| ^^^^^^^^^ ANN204
|
||||
41 | ...
|
||||
|
|
||||
= help: Add `None` return type
|
||||
|
||||
ℹ Suggested fix
|
||||
35 35 | def __int__(self):
|
||||
36 36 | ...
|
||||
37 37 |
|
||||
38 |- def __float__(self):
|
||||
38 |+ def __float__(self) -> float:
|
||||
39 39 | ...
|
||||
40 40 |
|
||||
41 41 | def __index__(self):
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/simple_magic_methods.py:41:9: ANN204 [*] Missing return type annotation for special method `__index__`
|
||||
|
|
||||
41 | ...
|
||||
42 |
|
||||
43 | def __index__(self):
|
||||
| ^^^^^^^^^ ANN204
|
||||
44 | ...
|
||||
|
|
||||
= help: Add `None` return type
|
||||
|
||||
ℹ Suggested fix
|
||||
38 38 | def __float__(self):
|
||||
39 39 | ...
|
||||
40 40 |
|
||||
41 |- def __index__(self):
|
||||
41 |+ def __index__(self) -> int:
|
||||
42 42 | ...
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
---
|
||||
source: src/rules/flake8_annotations/mod.rs
|
||||
expression: diagnostics
|
||||
source: crates/ruff/src/rules/flake8_annotations/mod.rs
|
||||
---
|
||||
[]
|
||||
|
||||
|
|
|
@ -1,47 +1,29 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_annotations/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: MissingReturnTypeUndocumentedPublicFunction
|
||||
body: "Missing return type annotation for public function `foo`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 45
|
||||
column: 4
|
||||
end_location:
|
||||
row: 45
|
||||
column: 7
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingReturnTypeUndocumentedPublicFunction
|
||||
body: "Missing return type annotation for public function `foo`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 50
|
||||
column: 4
|
||||
end_location:
|
||||
row: 50
|
||||
column: 7
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MissingTypeFunctionArgument
|
||||
body: "Missing type annotation for function argument `a`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 59
|
||||
column: 8
|
||||
end_location:
|
||||
row: 59
|
||||
column: 9
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_annotations/suppress_none_returning.py:45:5: ANN201 Missing return type annotation for public function `foo`
|
||||
|
|
||||
45 | # Error
|
||||
46 | def foo():
|
||||
| ^^^ ANN201
|
||||
47 | return True
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/suppress_none_returning.py:50:5: ANN201 Missing return type annotation for public function `foo`
|
||||
|
|
||||
50 | # Error
|
||||
51 | def foo():
|
||||
| ^^^ ANN201
|
||||
52 | a = 2 + 2
|
||||
53 | if a == 4:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_annotations/suppress_none_returning.py:59:9: ANN001 Missing type annotation for function argument `a`
|
||||
|
|
||||
59 | # Error (on the argument, but not the return type)
|
||||
60 | def foo(a):
|
||||
| ^ ANN001
|
||||
61 | a = 2 + 2
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -7,8 +7,9 @@ pub mod settings;
|
|||
mod tests {
|
||||
use std::path::Path;
|
||||
|
||||
use crate::assert_messages;
|
||||
use anyhow::Result;
|
||||
use insta::assert_yaml_snapshot;
|
||||
|
||||
use test_case::test_case;
|
||||
|
||||
use crate::registry::Rule;
|
||||
|
@ -42,7 +43,7 @@ mod tests {
|
|||
Path::new("flake8_bandit").join(path).as_path(),
|
||||
&Settings::for_rule(rule_code),
|
||||
)?;
|
||||
assert_yaml_snapshot!(snapshot, diagnostics);
|
||||
assert_messages!(snapshot, diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -63,7 +64,7 @@ mod tests {
|
|||
..Settings::for_rule(Rule::HardcodedTempFile)
|
||||
},
|
||||
)?;
|
||||
assert_yaml_snapshot!("S108_extend", diagnostics);
|
||||
assert_messages!("S108_extend", diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -79,7 +80,7 @@ mod tests {
|
|||
..Settings::for_rule(Rule::TryExceptPass)
|
||||
},
|
||||
)?;
|
||||
assert_yaml_snapshot!("S110_typed", diagnostics);
|
||||
assert_messages!("S110_typed", diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,47 +1,29 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: Assert
|
||||
body: "Use of `assert` detected"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 2
|
||||
column: 0
|
||||
end_location:
|
||||
row: 2
|
||||
column: 6
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: Assert
|
||||
body: "Use of `assert` detected"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 4
|
||||
end_location:
|
||||
row: 8
|
||||
column: 10
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: Assert
|
||||
body: "Use of `assert` detected"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 11
|
||||
column: 4
|
||||
end_location:
|
||||
row: 11
|
||||
column: 10
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S101.py:2:1: S101 Use of `assert` detected
|
||||
|
|
||||
2 | # Error
|
||||
3 | assert True
|
||||
| ^^^^^^ S101
|
||||
4 |
|
||||
5 | def fn():
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S101.py:8:5: S101 Use of `assert` detected
|
||||
|
|
||||
8 | # Error
|
||||
9 | assert x == 1
|
||||
| ^^^^^^ S101
|
||||
10 |
|
||||
11 | # Error
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S101.py:11:5: S101 Use of `assert` detected
|
||||
|
|
||||
11 | # Error
|
||||
12 | assert x == 2
|
||||
| ^^^^^^ S101
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,33 +1,22 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: ExecBuiltin
|
||||
body: "Use of `exec` detected"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 3
|
||||
column: 4
|
||||
end_location:
|
||||
row: 3
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ExecBuiltin
|
||||
body: "Use of `exec` detected"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 0
|
||||
end_location:
|
||||
row: 5
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S102.py:3:5: S102 Use of `exec` detected
|
||||
|
|
||||
3 | def fn():
|
||||
4 | # Error
|
||||
5 | exec('x = 2')
|
||||
| ^^^^^^^^^^^^^ S102
|
||||
6 |
|
||||
7 | exec('y = 3')
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S102.py:5:1: S102 Use of `exec` detected
|
||||
|
|
||||
5 | exec('x = 2')
|
||||
6 |
|
||||
7 | exec('y = 3')
|
||||
| ^^^^^^^^^^^^^ S102
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,187 +1,131 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: BadFilePermissions
|
||||
body: "`os.chmod` setting a permissive mask `0o227` on file or directory"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 6
|
||||
column: 24
|
||||
end_location:
|
||||
row: 6
|
||||
column: 29
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BadFilePermissions
|
||||
body: "`os.chmod` setting a permissive mask `0o7` on file or directory"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 7
|
||||
column: 24
|
||||
end_location:
|
||||
row: 7
|
||||
column: 27
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BadFilePermissions
|
||||
body: "`os.chmod` setting a permissive mask `0o777` on file or directory"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 9
|
||||
column: 24
|
||||
end_location:
|
||||
row: 9
|
||||
column: 29
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BadFilePermissions
|
||||
body: "`os.chmod` setting a permissive mask `0o770` on file or directory"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 10
|
||||
column: 24
|
||||
end_location:
|
||||
row: 10
|
||||
column: 29
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BadFilePermissions
|
||||
body: "`os.chmod` setting a permissive mask `0o776` on file or directory"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 11
|
||||
column: 24
|
||||
end_location:
|
||||
row: 11
|
||||
column: 29
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BadFilePermissions
|
||||
body: "`os.chmod` setting a permissive mask `0o777` on file or directory"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 22
|
||||
end_location:
|
||||
row: 13
|
||||
column: 25
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BadFilePermissions
|
||||
body: "`os.chmod` setting a permissive mask `0o777` on file or directory"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 14
|
||||
column: 23
|
||||
end_location:
|
||||
row: 14
|
||||
column: 28
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BadFilePermissions
|
||||
body: "`os.chmod` setting a permissive mask `0o777` on file or directory"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 15
|
||||
column: 24
|
||||
end_location:
|
||||
row: 15
|
||||
column: 29
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BadFilePermissions
|
||||
body: "`os.chmod` setting a permissive mask `0o777` on file or directory"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 17
|
||||
column: 18
|
||||
end_location:
|
||||
row: 17
|
||||
column: 23
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BadFilePermissions
|
||||
body: "`os.chmod` setting a permissive mask `0o777` on file or directory"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 18
|
||||
column: 18
|
||||
end_location:
|
||||
row: 18
|
||||
column: 36
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BadFilePermissions
|
||||
body: "`os.chmod` setting a permissive mask `0o777` on file or directory"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 19
|
||||
column: 18
|
||||
end_location:
|
||||
row: 19
|
||||
column: 60
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BadFilePermissions
|
||||
body: "`os.chmod` setting a permissive mask `0o10` on file or directory"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 20
|
||||
column: 26
|
||||
end_location:
|
||||
row: 20
|
||||
column: 38
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BadFilePermissions
|
||||
body: "`os.chmod` setting a permissive mask `0o2` on file or directory"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 22
|
||||
column: 24
|
||||
end_location:
|
||||
row: 22
|
||||
column: 36
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S103.py:6:25: S103 `os.chmod` setting a permissive mask `0o227` on file or directory
|
||||
|
|
||||
6 | keyfile = "foo"
|
||||
7 |
|
||||
8 | os.chmod("/etc/passwd", 0o227) # Error
|
||||
| ^^^^^ S103
|
||||
9 | os.chmod("/etc/passwd", 0o7) # Error
|
||||
10 | os.chmod("/etc/passwd", 0o664) # OK
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S103.py:7:25: S103 `os.chmod` setting a permissive mask `0o7` on file or directory
|
||||
|
|
||||
7 | os.chmod("/etc/passwd", 0o227) # Error
|
||||
8 | os.chmod("/etc/passwd", 0o7) # Error
|
||||
| ^^^ S103
|
||||
9 | os.chmod("/etc/passwd", 0o664) # OK
|
||||
10 | os.chmod("/etc/passwd", 0o777) # Error
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S103.py:9:25: S103 `os.chmod` setting a permissive mask `0o777` on file or directory
|
||||
|
|
||||
9 | os.chmod("/etc/passwd", 0o7) # Error
|
||||
10 | os.chmod("/etc/passwd", 0o664) # OK
|
||||
11 | os.chmod("/etc/passwd", 0o777) # Error
|
||||
| ^^^^^ S103
|
||||
12 | os.chmod("/etc/passwd", 0o770) # Error
|
||||
13 | os.chmod("/etc/passwd", 0o776) # Error
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S103.py:10:25: S103 `os.chmod` setting a permissive mask `0o770` on file or directory
|
||||
|
|
||||
10 | os.chmod("/etc/passwd", 0o664) # OK
|
||||
11 | os.chmod("/etc/passwd", 0o777) # Error
|
||||
12 | os.chmod("/etc/passwd", 0o770) # Error
|
||||
| ^^^^^ S103
|
||||
13 | os.chmod("/etc/passwd", 0o776) # Error
|
||||
14 | os.chmod("/etc/passwd", 0o760) # OK
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S103.py:11:25: S103 `os.chmod` setting a permissive mask `0o776` on file or directory
|
||||
|
|
||||
11 | os.chmod("/etc/passwd", 0o777) # Error
|
||||
12 | os.chmod("/etc/passwd", 0o770) # Error
|
||||
13 | os.chmod("/etc/passwd", 0o776) # Error
|
||||
| ^^^^^ S103
|
||||
14 | os.chmod("/etc/passwd", 0o760) # OK
|
||||
15 | os.chmod("~/.bashrc", 511) # Error
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S103.py:13:23: S103 `os.chmod` setting a permissive mask `0o777` on file or directory
|
||||
|
|
||||
13 | os.chmod("/etc/passwd", 0o776) # Error
|
||||
14 | os.chmod("/etc/passwd", 0o760) # OK
|
||||
15 | os.chmod("~/.bashrc", 511) # Error
|
||||
| ^^^ S103
|
||||
16 | os.chmod("/etc/hosts", 0o777) # Error
|
||||
17 | os.chmod("/tmp/oh_hai", 0x1FF) # Error
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S103.py:14:24: S103 `os.chmod` setting a permissive mask `0o777` on file or directory
|
||||
|
|
||||
14 | os.chmod("/etc/passwd", 0o760) # OK
|
||||
15 | os.chmod("~/.bashrc", 511) # Error
|
||||
16 | os.chmod("/etc/hosts", 0o777) # Error
|
||||
| ^^^^^ S103
|
||||
17 | os.chmod("/tmp/oh_hai", 0x1FF) # Error
|
||||
18 | os.chmod("/etc/passwd", stat.S_IRWXU) # OK
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S103.py:15:25: S103 `os.chmod` setting a permissive mask `0o777` on file or directory
|
||||
|
|
||||
15 | os.chmod("~/.bashrc", 511) # Error
|
||||
16 | os.chmod("/etc/hosts", 0o777) # Error
|
||||
17 | os.chmod("/tmp/oh_hai", 0x1FF) # Error
|
||||
| ^^^^^ S103
|
||||
18 | os.chmod("/etc/passwd", stat.S_IRWXU) # OK
|
||||
19 | os.chmod(keyfile, 0o777) # Error
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S103.py:17:19: S103 `os.chmod` setting a permissive mask `0o777` on file or directory
|
||||
|
|
||||
17 | os.chmod("/tmp/oh_hai", 0x1FF) # Error
|
||||
18 | os.chmod("/etc/passwd", stat.S_IRWXU) # OK
|
||||
19 | os.chmod(keyfile, 0o777) # Error
|
||||
| ^^^^^ S103
|
||||
20 | os.chmod(keyfile, 0o7 | 0o70 | 0o700) # Error
|
||||
21 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU) # Error
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S103.py:18:19: S103 `os.chmod` setting a permissive mask `0o777` on file or directory
|
||||
|
|
||||
18 | os.chmod("/etc/passwd", stat.S_IRWXU) # OK
|
||||
19 | os.chmod(keyfile, 0o777) # Error
|
||||
20 | os.chmod(keyfile, 0o7 | 0o70 | 0o700) # Error
|
||||
| ^^^^^^^^^^^^^^^^^^ S103
|
||||
21 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU) # Error
|
||||
22 | os.chmod("~/hidden_exec", stat.S_IXGRP) # Error
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S103.py:19:19: S103 `os.chmod` setting a permissive mask `0o777` on file or directory
|
||||
|
|
||||
19 | os.chmod(keyfile, 0o777) # Error
|
||||
20 | os.chmod(keyfile, 0o7 | 0o70 | 0o700) # Error
|
||||
21 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU) # Error
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S103
|
||||
22 | os.chmod("~/hidden_exec", stat.S_IXGRP) # Error
|
||||
23 | os.chmod("~/hidden_exec", stat.S_IXOTH) # OK
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S103.py:20:27: S103 `os.chmod` setting a permissive mask `0o10` on file or directory
|
||||
|
|
||||
20 | os.chmod(keyfile, 0o7 | 0o70 | 0o700) # Error
|
||||
21 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU) # Error
|
||||
22 | os.chmod("~/hidden_exec", stat.S_IXGRP) # Error
|
||||
| ^^^^^^^^^^^^ S103
|
||||
23 | os.chmod("~/hidden_exec", stat.S_IXOTH) # OK
|
||||
24 | os.chmod("/etc/passwd", stat.S_IWOTH) # Error
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S103.py:22:25: S103 `os.chmod` setting a permissive mask `0o2` on file or directory
|
||||
|
|
||||
22 | os.chmod("~/hidden_exec", stat.S_IXGRP) # Error
|
||||
23 | os.chmod("~/hidden_exec", stat.S_IXOTH) # OK
|
||||
24 | os.chmod("/etc/passwd", stat.S_IWOTH) # Error
|
||||
| ^^^^^^^^^^^^ S103
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,61 +1,35 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: HardcodedBindAllInterfaces
|
||||
body: Possible binding to all interfaces
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 9
|
||||
column: 0
|
||||
end_location:
|
||||
row: 9
|
||||
column: 9
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedBindAllInterfaces
|
||||
body: Possible binding to all interfaces
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 10
|
||||
column: 0
|
||||
end_location:
|
||||
row: 10
|
||||
column: 9
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedBindAllInterfaces
|
||||
body: Possible binding to all interfaces
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 14
|
||||
column: 5
|
||||
end_location:
|
||||
row: 14
|
||||
column: 14
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedBindAllInterfaces
|
||||
body: Possible binding to all interfaces
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 18
|
||||
column: 8
|
||||
end_location:
|
||||
row: 18
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S104.py:9:1: S104 Possible binding to all interfaces
|
||||
|
|
||||
9 | # Error
|
||||
10 | "0.0.0.0"
|
||||
| ^^^^^^^^^ S104
|
||||
11 | '0.0.0.0'
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S104.py:10:1: S104 Possible binding to all interfaces
|
||||
|
|
||||
10 | # Error
|
||||
11 | "0.0.0.0"
|
||||
12 | '0.0.0.0'
|
||||
| ^^^^^^^^^ S104
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S104.py:14:6: S104 Possible binding to all interfaces
|
||||
|
|
||||
14 | # Error
|
||||
15 | func("0.0.0.0")
|
||||
| ^^^^^^^^^ S104
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S104.py:18:9: S104 Possible binding to all interfaces
|
||||
|
|
||||
18 | def my_func():
|
||||
19 | x = "0.0.0.0"
|
||||
| ^^^^^^^^^ S104
|
||||
20 | print(x)
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,551 +1,377 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 11
|
||||
end_location:
|
||||
row: 13
|
||||
column: 19
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 14
|
||||
column: 8
|
||||
end_location:
|
||||
row: 14
|
||||
column: 16
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 15
|
||||
column: 9
|
||||
end_location:
|
||||
row: 15
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 16
|
||||
column: 6
|
||||
end_location:
|
||||
row: 16
|
||||
column: 14
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 17
|
||||
column: 9
|
||||
end_location:
|
||||
row: 17
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 18
|
||||
column: 8
|
||||
end_location:
|
||||
row: 18
|
||||
column: 16
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 19
|
||||
column: 10
|
||||
end_location:
|
||||
row: 19
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 20
|
||||
column: 18
|
||||
end_location:
|
||||
row: 20
|
||||
column: 26
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 21
|
||||
column: 18
|
||||
end_location:
|
||||
row: 21
|
||||
column: 26
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 22
|
||||
column: 11
|
||||
end_location:
|
||||
row: 22
|
||||
column: 19
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 23
|
||||
column: 11
|
||||
end_location:
|
||||
row: 23
|
||||
column: 19
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 25
|
||||
column: 16
|
||||
end_location:
|
||||
row: 25
|
||||
column: 24
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 26
|
||||
column: 12
|
||||
end_location:
|
||||
row: 26
|
||||
column: 20
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 27
|
||||
column: 14
|
||||
end_location:
|
||||
row: 27
|
||||
column: 22
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 28
|
||||
column: 11
|
||||
end_location:
|
||||
row: 28
|
||||
column: 19
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 29
|
||||
column: 14
|
||||
end_location:
|
||||
row: 29
|
||||
column: 22
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 30
|
||||
column: 13
|
||||
end_location:
|
||||
row: 30
|
||||
column: 21
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 31
|
||||
column: 15
|
||||
end_location:
|
||||
row: 31
|
||||
column: 23
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 32
|
||||
column: 23
|
||||
end_location:
|
||||
row: 32
|
||||
column: 31
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 33
|
||||
column: 23
|
||||
end_location:
|
||||
row: 33
|
||||
column: 31
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 37
|
||||
column: 15
|
||||
end_location:
|
||||
row: 37
|
||||
column: 23
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 41
|
||||
column: 19
|
||||
end_location:
|
||||
row: 41
|
||||
column: 27
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 42
|
||||
column: 16
|
||||
end_location:
|
||||
row: 42
|
||||
column: 24
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 43
|
||||
column: 17
|
||||
end_location:
|
||||
row: 43
|
||||
column: 25
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 44
|
||||
column: 14
|
||||
end_location:
|
||||
row: 44
|
||||
column: 22
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 45
|
||||
column: 17
|
||||
end_location:
|
||||
row: 45
|
||||
column: 25
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 46
|
||||
column: 16
|
||||
end_location:
|
||||
row: 46
|
||||
column: 24
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 47
|
||||
column: 18
|
||||
end_location:
|
||||
row: 47
|
||||
column: 26
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 49
|
||||
column: 12
|
||||
end_location:
|
||||
row: 49
|
||||
column: 20
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 50
|
||||
column: 9
|
||||
end_location:
|
||||
row: 50
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 51
|
||||
column: 10
|
||||
end_location:
|
||||
row: 51
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 52
|
||||
column: 7
|
||||
end_location:
|
||||
row: 52
|
||||
column: 15
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 53
|
||||
column: 10
|
||||
end_location:
|
||||
row: 53
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 54
|
||||
column: 9
|
||||
end_location:
|
||||
row: 54
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 55
|
||||
column: 11
|
||||
end_location:
|
||||
row: 55
|
||||
column: 19
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 56
|
||||
column: 20
|
||||
end_location:
|
||||
row: 56
|
||||
column: 28
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"1\\n2\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 58
|
||||
column: 12
|
||||
end_location:
|
||||
row: 58
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"3\\t4\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 61
|
||||
column: 12
|
||||
end_location:
|
||||
row: 61
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordString
|
||||
body: "Possible hardcoded password: \"5\\r6\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 64
|
||||
column: 12
|
||||
end_location:
|
||||
row: 64
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:13:12: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
13 | # Errors
|
||||
14 | password = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
15 | _pass = "s3cr3t"
|
||||
16 | passwd = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:14:9: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
14 | # Errors
|
||||
15 | password = "s3cr3t"
|
||||
16 | _pass = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
17 | passwd = "s3cr3t"
|
||||
18 | pwd = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:15:10: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
15 | password = "s3cr3t"
|
||||
16 | _pass = "s3cr3t"
|
||||
17 | passwd = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
18 | pwd = "s3cr3t"
|
||||
19 | secret = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:16:7: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
16 | _pass = "s3cr3t"
|
||||
17 | passwd = "s3cr3t"
|
||||
18 | pwd = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
19 | secret = "s3cr3t"
|
||||
20 | token = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:17:10: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
17 | passwd = "s3cr3t"
|
||||
18 | pwd = "s3cr3t"
|
||||
19 | secret = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
20 | token = "s3cr3t"
|
||||
21 | secrete = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:18:9: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
18 | pwd = "s3cr3t"
|
||||
19 | secret = "s3cr3t"
|
||||
20 | token = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
21 | secrete = "s3cr3t"
|
||||
22 | safe = password = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:19:11: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
19 | secret = "s3cr3t"
|
||||
20 | token = "s3cr3t"
|
||||
21 | secrete = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
22 | safe = password = "s3cr3t"
|
||||
23 | password = safe = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:20:19: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
20 | token = "s3cr3t"
|
||||
21 | secrete = "s3cr3t"
|
||||
22 | safe = password = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
23 | password = safe = "s3cr3t"
|
||||
24 | PASSWORD = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:21:19: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
21 | secrete = "s3cr3t"
|
||||
22 | safe = password = "s3cr3t"
|
||||
23 | password = safe = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
24 | PASSWORD = "s3cr3t"
|
||||
25 | PassWord = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:22:12: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
22 | safe = password = "s3cr3t"
|
||||
23 | password = safe = "s3cr3t"
|
||||
24 | PASSWORD = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
25 | PassWord = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:23:12: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
23 | password = safe = "s3cr3t"
|
||||
24 | PASSWORD = "s3cr3t"
|
||||
25 | PassWord = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
26 |
|
||||
27 | d["password"] = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:25:17: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
25 | PassWord = "s3cr3t"
|
||||
26 |
|
||||
27 | d["password"] = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
28 | d["pass"] = "s3cr3t"
|
||||
29 | d["passwd"] = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:26:13: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
26 | d["password"] = "s3cr3t"
|
||||
27 | d["pass"] = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
28 | d["passwd"] = "s3cr3t"
|
||||
29 | d["pwd"] = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:27:15: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
27 | d["password"] = "s3cr3t"
|
||||
28 | d["pass"] = "s3cr3t"
|
||||
29 | d["passwd"] = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
30 | d["pwd"] = "s3cr3t"
|
||||
31 | d["secret"] = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:28:12: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
28 | d["pass"] = "s3cr3t"
|
||||
29 | d["passwd"] = "s3cr3t"
|
||||
30 | d["pwd"] = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
31 | d["secret"] = "s3cr3t"
|
||||
32 | d["token"] = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:29:15: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
29 | d["passwd"] = "s3cr3t"
|
||||
30 | d["pwd"] = "s3cr3t"
|
||||
31 | d["secret"] = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
32 | d["token"] = "s3cr3t"
|
||||
33 | d["secrete"] = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:30:14: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
30 | d["pwd"] = "s3cr3t"
|
||||
31 | d["secret"] = "s3cr3t"
|
||||
32 | d["token"] = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
33 | d["secrete"] = "s3cr3t"
|
||||
34 | safe = d["password"] = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:31:16: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
31 | d["secret"] = "s3cr3t"
|
||||
32 | d["token"] = "s3cr3t"
|
||||
33 | d["secrete"] = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
34 | safe = d["password"] = "s3cr3t"
|
||||
35 | d["password"] = safe = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:32:24: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
32 | d["token"] = "s3cr3t"
|
||||
33 | d["secrete"] = "s3cr3t"
|
||||
34 | safe = d["password"] = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
35 | d["password"] = safe = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:33:24: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
33 | d["secrete"] = "s3cr3t"
|
||||
34 | safe = d["password"] = "s3cr3t"
|
||||
35 | d["password"] = safe = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:37:16: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
37 | class MyClass:
|
||||
38 | password = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
39 | safe = password
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:41:20: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
41 | MyClass.password = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
42 | MyClass._pass = "s3cr3t"
|
||||
43 | MyClass.passwd = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:42:17: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
42 | MyClass.password = "s3cr3t"
|
||||
43 | MyClass._pass = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
44 | MyClass.passwd = "s3cr3t"
|
||||
45 | MyClass.pwd = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:43:18: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
43 | MyClass.password = "s3cr3t"
|
||||
44 | MyClass._pass = "s3cr3t"
|
||||
45 | MyClass.passwd = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
46 | MyClass.pwd = "s3cr3t"
|
||||
47 | MyClass.secret = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:44:15: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
44 | MyClass._pass = "s3cr3t"
|
||||
45 | MyClass.passwd = "s3cr3t"
|
||||
46 | MyClass.pwd = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
47 | MyClass.secret = "s3cr3t"
|
||||
48 | MyClass.token = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:45:18: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
45 | MyClass.passwd = "s3cr3t"
|
||||
46 | MyClass.pwd = "s3cr3t"
|
||||
47 | MyClass.secret = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
48 | MyClass.token = "s3cr3t"
|
||||
49 | MyClass.secrete = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:46:17: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
46 | MyClass.pwd = "s3cr3t"
|
||||
47 | MyClass.secret = "s3cr3t"
|
||||
48 | MyClass.token = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
49 | MyClass.secrete = "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:47:19: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
47 | MyClass.secret = "s3cr3t"
|
||||
48 | MyClass.token = "s3cr3t"
|
||||
49 | MyClass.secrete = "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
50 |
|
||||
51 | password == "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:49:13: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
49 | MyClass.secrete = "s3cr3t"
|
||||
50 |
|
||||
51 | password == "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
52 | _pass == "s3cr3t"
|
||||
53 | passwd == "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:50:10: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
50 | password == "s3cr3t"
|
||||
51 | _pass == "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
52 | passwd == "s3cr3t"
|
||||
53 | pwd == "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:51:11: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
51 | password == "s3cr3t"
|
||||
52 | _pass == "s3cr3t"
|
||||
53 | passwd == "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
54 | pwd == "s3cr3t"
|
||||
55 | secret == "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:52:8: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
52 | _pass == "s3cr3t"
|
||||
53 | passwd == "s3cr3t"
|
||||
54 | pwd == "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
55 | secret == "s3cr3t"
|
||||
56 | token == "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:53:11: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
53 | passwd == "s3cr3t"
|
||||
54 | pwd == "s3cr3t"
|
||||
55 | secret == "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
56 | token == "s3cr3t"
|
||||
57 | secrete == "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:54:10: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
54 | pwd == "s3cr3t"
|
||||
55 | secret == "s3cr3t"
|
||||
56 | token == "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
57 | secrete == "s3cr3t"
|
||||
58 | password == safe == "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:55:12: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
55 | secret == "s3cr3t"
|
||||
56 | token == "s3cr3t"
|
||||
57 | secrete == "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
58 | password == safe == "s3cr3t"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:56:21: S105 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
56 | token == "s3cr3t"
|
||||
57 | secrete == "s3cr3t"
|
||||
58 | password == safe == "s3cr3t"
|
||||
| ^^^^^^^^ S105
|
||||
59 |
|
||||
60 | if token == "1\n2":
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:58:13: S105 Possible hardcoded password: "1\n2"
|
||||
|
|
||||
58 | password == safe == "s3cr3t"
|
||||
59 |
|
||||
60 | if token == "1\n2":
|
||||
| ^^^^^^ S105
|
||||
61 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:61:13: S105 Possible hardcoded password: "3\t4"
|
||||
|
|
||||
61 | pass
|
||||
62 |
|
||||
63 | if token == "3\t4":
|
||||
| ^^^^^^ S105
|
||||
64 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S105.py:64:13: S105 Possible hardcoded password: "5\r6"
|
||||
|
|
||||
64 | pass
|
||||
65 |
|
||||
66 | if token == "5\r6":
|
||||
| ^^^^^^ S105
|
||||
67 | pass
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,19 +1,11 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: HardcodedPasswordFuncArg
|
||||
body: "Possible hardcoded password: \"s3cr3t\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 14
|
||||
column: 8
|
||||
end_location:
|
||||
row: 14
|
||||
column: 25
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S106.py:14:9: S106 Possible hardcoded password: "s3cr3t"
|
||||
|
|
||||
14 | # Error
|
||||
15 | func(1, password="s3cr3t")
|
||||
| ^^^^^^^^^^^^^^^^^ S106
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,75 +1,39 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: HardcodedPasswordDefault
|
||||
body: "Possible hardcoded password: \"default\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 28
|
||||
end_location:
|
||||
row: 5
|
||||
column: 37
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordDefault
|
||||
body: "Possible hardcoded password: \"posonly\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 44
|
||||
end_location:
|
||||
row: 13
|
||||
column: 53
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordDefault
|
||||
body: "Possible hardcoded password: \"kwonly\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 21
|
||||
column: 38
|
||||
end_location:
|
||||
row: 21
|
||||
column: 46
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordDefault
|
||||
body: "Possible hardcoded password: \"posonly\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 29
|
||||
column: 38
|
||||
end_location:
|
||||
row: 29
|
||||
column: 47
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedPasswordDefault
|
||||
body: "Possible hardcoded password: \"kwonly\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 29
|
||||
column: 61
|
||||
end_location:
|
||||
row: 29
|
||||
column: 69
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S107.py:5:29: S107 Possible hardcoded password: "default"
|
||||
|
|
||||
5 | def default(first, password="default"):
|
||||
| ^^^^^^^^^ S107
|
||||
6 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S107.py:13:45: S107 Possible hardcoded password: "posonly"
|
||||
|
|
||||
13 | def default_posonly(first, /, pos, password="posonly"):
|
||||
| ^^^^^^^^^ S107
|
||||
14 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S107.py:21:39: S107 Possible hardcoded password: "kwonly"
|
||||
|
|
||||
21 | def default_kwonly(first, *, password="kwonly"):
|
||||
| ^^^^^^^^ S107
|
||||
22 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S107.py:29:39: S107 Possible hardcoded password: "posonly"
|
||||
|
|
||||
29 | def default_all(first, /, pos, secret="posonly", *, password="kwonly"):
|
||||
| ^^^^^^^^^ S107
|
||||
30 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S107.py:29:62: S107 Possible hardcoded password: "kwonly"
|
||||
|
|
||||
29 | def default_all(first, /, pos, secret="posonly", *, password="kwonly"):
|
||||
| ^^^^^^^^ S107
|
||||
30 | pass
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,47 +1,31 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: HardcodedTempFile
|
||||
body: "Probable insecure usage of temporary file or directory: \"/tmp/abc\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 10
|
||||
end_location:
|
||||
row: 5
|
||||
column: 20
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedTempFile
|
||||
body: "Probable insecure usage of temporary file or directory: \"/var/tmp/123\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 10
|
||||
end_location:
|
||||
row: 8
|
||||
column: 24
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedTempFile
|
||||
body: "Probable insecure usage of temporary file or directory: \"/dev/shm/unit/test\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 11
|
||||
column: 10
|
||||
end_location:
|
||||
row: 11
|
||||
column: 30
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S108.py:5:11: S108 Probable insecure usage of temporary file or directory: "/tmp/abc"
|
||||
|
|
||||
5 | f.write("def")
|
||||
6 |
|
||||
7 | with open("/tmp/abc", "w") as f:
|
||||
| ^^^^^^^^^^ S108
|
||||
8 | f.write("def")
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S108.py:8:11: S108 Probable insecure usage of temporary file or directory: "/var/tmp/123"
|
||||
|
|
||||
8 | f.write("def")
|
||||
9 |
|
||||
10 | with open("/var/tmp/123", "w") as f:
|
||||
| ^^^^^^^^^^^^^^ S108
|
||||
11 | f.write("def")
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S108.py:11:11: S108 Probable insecure usage of temporary file or directory: "/dev/shm/unit/test"
|
||||
|
|
||||
11 | f.write("def")
|
||||
12 |
|
||||
13 | with open("/dev/shm/unit/test", "w") as f:
|
||||
| ^^^^^^^^^^^^^^^^^^^^ S108
|
||||
14 | f.write("def")
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,61 +1,39 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: HardcodedTempFile
|
||||
body: "Probable insecure usage of temporary file or directory: \"/tmp/abc\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 10
|
||||
end_location:
|
||||
row: 5
|
||||
column: 20
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedTempFile
|
||||
body: "Probable insecure usage of temporary file or directory: \"/var/tmp/123\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 10
|
||||
end_location:
|
||||
row: 8
|
||||
column: 24
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedTempFile
|
||||
body: "Probable insecure usage of temporary file or directory: \"/dev/shm/unit/test\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 11
|
||||
column: 10
|
||||
end_location:
|
||||
row: 11
|
||||
column: 30
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HardcodedTempFile
|
||||
body: "Probable insecure usage of temporary file or directory: \"/foo/bar\""
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 15
|
||||
column: 10
|
||||
end_location:
|
||||
row: 15
|
||||
column: 20
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S108.py:5:11: S108 Probable insecure usage of temporary file or directory: "/tmp/abc"
|
||||
|
|
||||
5 | f.write("def")
|
||||
6 |
|
||||
7 | with open("/tmp/abc", "w") as f:
|
||||
| ^^^^^^^^^^ S108
|
||||
8 | f.write("def")
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S108.py:8:11: S108 Probable insecure usage of temporary file or directory: "/var/tmp/123"
|
||||
|
|
||||
8 | f.write("def")
|
||||
9 |
|
||||
10 | with open("/var/tmp/123", "w") as f:
|
||||
| ^^^^^^^^^^^^^^ S108
|
||||
11 | f.write("def")
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S108.py:11:11: S108 Probable insecure usage of temporary file or directory: "/dev/shm/unit/test"
|
||||
|
|
||||
11 | f.write("def")
|
||||
12 |
|
||||
13 | with open("/dev/shm/unit/test", "w") as f:
|
||||
| ^^^^^^^^^^^^^^^^^^^^ S108
|
||||
14 | f.write("def")
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S108.py:15:11: S108 Probable insecure usage of temporary file or directory: "/foo/bar"
|
||||
|
|
||||
15 | # not ok by config
|
||||
16 | with open("/foo/bar", "w") as f:
|
||||
| ^^^^^^^^^^ S108
|
||||
17 | f.write("def")
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,33 +1,26 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: TryExceptPass
|
||||
body: "`try`-`except`-`pass` detected, consider logging the exception"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 3
|
||||
column: 0
|
||||
end_location:
|
||||
row: 4
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: TryExceptPass
|
||||
body: "`try`-`except`-`pass` detected, consider logging the exception"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 0
|
||||
end_location:
|
||||
row: 9
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S110.py:3:1: S110 `try`-`except`-`pass` detected, consider logging the exception
|
||||
|
|
||||
3 | try:
|
||||
4 | pass
|
||||
5 | / except Exception:
|
||||
6 | | pass
|
||||
| |________^ S110
|
||||
7 |
|
||||
8 | try:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S110.py:8:1: S110 `try`-`except`-`pass` detected, consider logging the exception
|
||||
|
|
||||
8 | try:
|
||||
9 | pass
|
||||
10 | / except:
|
||||
11 | | pass
|
||||
| |________^ S110
|
||||
12 |
|
||||
13 | try:
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,47 +1,35 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: TryExceptPass
|
||||
body: "`try`-`except`-`pass` detected, consider logging the exception"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 3
|
||||
column: 0
|
||||
end_location:
|
||||
row: 4
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: TryExceptPass
|
||||
body: "`try`-`except`-`pass` detected, consider logging the exception"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 0
|
||||
end_location:
|
||||
row: 9
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: TryExceptPass
|
||||
body: "`try`-`except`-`pass` detected, consider logging the exception"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 0
|
||||
end_location:
|
||||
row: 14
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S110.py:3:1: S110 `try`-`except`-`pass` detected, consider logging the exception
|
||||
|
|
||||
3 | try:
|
||||
4 | pass
|
||||
5 | / except Exception:
|
||||
6 | | pass
|
||||
| |________^ S110
|
||||
7 |
|
||||
8 | try:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S110.py:8:1: S110 `try`-`except`-`pass` detected, consider logging the exception
|
||||
|
|
||||
8 | try:
|
||||
9 | pass
|
||||
10 | / except:
|
||||
11 | | pass
|
||||
| |________^ S110
|
||||
12 |
|
||||
13 | try:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S110.py:13:1: S110 `try`-`except`-`pass` detected, consider logging the exception
|
||||
|
|
||||
13 | try:
|
||||
14 | pass
|
||||
15 | / except ValueError:
|
||||
16 | | pass
|
||||
| |________^ S110
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,61 +1,48 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: TryExceptContinue
|
||||
body: "`try`-`except`-`continue` detected, consider logging the exception"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 3
|
||||
column: 0
|
||||
end_location:
|
||||
row: 4
|
||||
column: 12
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: TryExceptContinue
|
||||
body: "`try`-`except`-`continue` detected, consider logging the exception"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 0
|
||||
end_location:
|
||||
row: 9
|
||||
column: 12
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: TryExceptContinue
|
||||
body: "`try`-`except`-`continue` detected, consider logging the exception"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 0
|
||||
end_location:
|
||||
row: 14
|
||||
column: 12
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: TryExceptContinue
|
||||
body: "`try`-`except`-`continue` detected, consider logging the exception"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 18
|
||||
column: 0
|
||||
end_location:
|
||||
row: 19
|
||||
column: 12
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S112.py:3:1: S112 `try`-`except`-`continue` detected, consider logging the exception
|
||||
|
|
||||
3 | try:
|
||||
4 | pass
|
||||
5 | / except Exception:
|
||||
6 | | continue
|
||||
| |____________^ S112
|
||||
7 |
|
||||
8 | try:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S112.py:8:1: S112 `try`-`except`-`continue` detected, consider logging the exception
|
||||
|
|
||||
8 | try:
|
||||
9 | pass
|
||||
10 | / except:
|
||||
11 | | continue
|
||||
| |____________^ S112
|
||||
12 |
|
||||
13 | try:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S112.py:13:1: S112 `try`-`except`-`continue` detected, consider logging the exception
|
||||
|
|
||||
13 | try:
|
||||
14 | pass
|
||||
15 | / except (Exception,):
|
||||
16 | | continue
|
||||
| |____________^ S112
|
||||
17 |
|
||||
18 | try:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S112.py:18:1: S112 `try`-`except`-`continue` detected, consider logging the exception
|
||||
|
|
||||
18 | try:
|
||||
19 | pass
|
||||
20 | / except (Exception, ValueError):
|
||||
21 | | continue
|
||||
| |____________^ S112
|
||||
22 |
|
||||
23 | try:
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,201 +1,142 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: RequestWithoutTimeout
|
||||
body: Probable use of requests call without timeout
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 3
|
||||
column: 0
|
||||
end_location:
|
||||
row: 3
|
||||
column: 12
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithoutTimeout
|
||||
body: "Probable use of requests call with timeout set to `None`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 42
|
||||
end_location:
|
||||
row: 4
|
||||
column: 46
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithoutTimeout
|
||||
body: Probable use of requests call without timeout
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 6
|
||||
column: 0
|
||||
end_location:
|
||||
row: 6
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithoutTimeout
|
||||
body: "Probable use of requests call with timeout set to `None`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 7
|
||||
column: 43
|
||||
end_location:
|
||||
row: 7
|
||||
column: 47
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithoutTimeout
|
||||
body: Probable use of requests call without timeout
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 9
|
||||
column: 0
|
||||
end_location:
|
||||
row: 9
|
||||
column: 12
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithoutTimeout
|
||||
body: "Probable use of requests call with timeout set to `None`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 10
|
||||
column: 42
|
||||
end_location:
|
||||
row: 10
|
||||
column: 46
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithoutTimeout
|
||||
body: Probable use of requests call without timeout
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 12
|
||||
column: 0
|
||||
end_location:
|
||||
row: 12
|
||||
column: 15
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithoutTimeout
|
||||
body: "Probable use of requests call with timeout set to `None`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 45
|
||||
end_location:
|
||||
row: 13
|
||||
column: 49
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithoutTimeout
|
||||
body: Probable use of requests call without timeout
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 15
|
||||
column: 0
|
||||
end_location:
|
||||
row: 15
|
||||
column: 14
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithoutTimeout
|
||||
body: "Probable use of requests call with timeout set to `None`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 16
|
||||
column: 44
|
||||
end_location:
|
||||
row: 16
|
||||
column: 48
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithoutTimeout
|
||||
body: Probable use of requests call without timeout
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 18
|
||||
column: 0
|
||||
end_location:
|
||||
row: 18
|
||||
column: 16
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithoutTimeout
|
||||
body: "Probable use of requests call with timeout set to `None`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 19
|
||||
column: 46
|
||||
end_location:
|
||||
row: 19
|
||||
column: 50
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithoutTimeout
|
||||
body: Probable use of requests call without timeout
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 21
|
||||
column: 0
|
||||
end_location:
|
||||
row: 21
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithoutTimeout
|
||||
body: "Probable use of requests call with timeout set to `None`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 22
|
||||
column: 43
|
||||
end_location:
|
||||
row: 22
|
||||
column: 47
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S113.py:3:1: S113 Probable use of requests call without timeout
|
||||
|
|
||||
3 | import requests
|
||||
4 |
|
||||
5 | requests.get('https://gmail.com')
|
||||
| ^^^^^^^^^^^^ S113
|
||||
6 | requests.get('https://gmail.com', timeout=None)
|
||||
7 | requests.get('https://gmail.com', timeout=5)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S113.py:4:43: S113 Probable use of requests call with timeout set to `None`
|
||||
|
|
||||
4 | requests.get('https://gmail.com')
|
||||
5 | requests.get('https://gmail.com', timeout=None)
|
||||
| ^^^^ S113
|
||||
6 | requests.get('https://gmail.com', timeout=5)
|
||||
7 | requests.post('https://gmail.com')
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S113.py:6:1: S113 Probable use of requests call without timeout
|
||||
|
|
||||
6 | requests.get('https://gmail.com', timeout=None)
|
||||
7 | requests.get('https://gmail.com', timeout=5)
|
||||
8 | requests.post('https://gmail.com')
|
||||
| ^^^^^^^^^^^^^ S113
|
||||
9 | requests.post('https://gmail.com', timeout=None)
|
||||
10 | requests.post('https://gmail.com', timeout=5)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S113.py:7:44: S113 Probable use of requests call with timeout set to `None`
|
||||
|
|
||||
7 | requests.get('https://gmail.com', timeout=5)
|
||||
8 | requests.post('https://gmail.com')
|
||||
9 | requests.post('https://gmail.com', timeout=None)
|
||||
| ^^^^ S113
|
||||
10 | requests.post('https://gmail.com', timeout=5)
|
||||
11 | requests.put('https://gmail.com')
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S113.py:9:1: S113 Probable use of requests call without timeout
|
||||
|
|
||||
9 | requests.post('https://gmail.com', timeout=None)
|
||||
10 | requests.post('https://gmail.com', timeout=5)
|
||||
11 | requests.put('https://gmail.com')
|
||||
| ^^^^^^^^^^^^ S113
|
||||
12 | requests.put('https://gmail.com', timeout=None)
|
||||
13 | requests.put('https://gmail.com', timeout=5)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S113.py:10:43: S113 Probable use of requests call with timeout set to `None`
|
||||
|
|
||||
10 | requests.post('https://gmail.com', timeout=5)
|
||||
11 | requests.put('https://gmail.com')
|
||||
12 | requests.put('https://gmail.com', timeout=None)
|
||||
| ^^^^ S113
|
||||
13 | requests.put('https://gmail.com', timeout=5)
|
||||
14 | requests.delete('https://gmail.com')
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S113.py:12:1: S113 Probable use of requests call without timeout
|
||||
|
|
||||
12 | requests.put('https://gmail.com', timeout=None)
|
||||
13 | requests.put('https://gmail.com', timeout=5)
|
||||
14 | requests.delete('https://gmail.com')
|
||||
| ^^^^^^^^^^^^^^^ S113
|
||||
15 | requests.delete('https://gmail.com', timeout=None)
|
||||
16 | requests.delete('https://gmail.com', timeout=5)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S113.py:13:46: S113 Probable use of requests call with timeout set to `None`
|
||||
|
|
||||
13 | requests.put('https://gmail.com', timeout=5)
|
||||
14 | requests.delete('https://gmail.com')
|
||||
15 | requests.delete('https://gmail.com', timeout=None)
|
||||
| ^^^^ S113
|
||||
16 | requests.delete('https://gmail.com', timeout=5)
|
||||
17 | requests.patch('https://gmail.com')
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S113.py:15:1: S113 Probable use of requests call without timeout
|
||||
|
|
||||
15 | requests.delete('https://gmail.com', timeout=None)
|
||||
16 | requests.delete('https://gmail.com', timeout=5)
|
||||
17 | requests.patch('https://gmail.com')
|
||||
| ^^^^^^^^^^^^^^ S113
|
||||
18 | requests.patch('https://gmail.com', timeout=None)
|
||||
19 | requests.patch('https://gmail.com', timeout=5)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S113.py:16:45: S113 Probable use of requests call with timeout set to `None`
|
||||
|
|
||||
16 | requests.delete('https://gmail.com', timeout=5)
|
||||
17 | requests.patch('https://gmail.com')
|
||||
18 | requests.patch('https://gmail.com', timeout=None)
|
||||
| ^^^^ S113
|
||||
19 | requests.patch('https://gmail.com', timeout=5)
|
||||
20 | requests.options('https://gmail.com')
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S113.py:18:1: S113 Probable use of requests call without timeout
|
||||
|
|
||||
18 | requests.patch('https://gmail.com', timeout=None)
|
||||
19 | requests.patch('https://gmail.com', timeout=5)
|
||||
20 | requests.options('https://gmail.com')
|
||||
| ^^^^^^^^^^^^^^^^ S113
|
||||
21 | requests.options('https://gmail.com', timeout=None)
|
||||
22 | requests.options('https://gmail.com', timeout=5)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S113.py:19:47: S113 Probable use of requests call with timeout set to `None`
|
||||
|
|
||||
19 | requests.patch('https://gmail.com', timeout=5)
|
||||
20 | requests.options('https://gmail.com')
|
||||
21 | requests.options('https://gmail.com', timeout=None)
|
||||
| ^^^^ S113
|
||||
22 | requests.options('https://gmail.com', timeout=5)
|
||||
23 | requests.head('https://gmail.com')
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S113.py:21:1: S113 Probable use of requests call without timeout
|
||||
|
|
||||
21 | requests.options('https://gmail.com', timeout=None)
|
||||
22 | requests.options('https://gmail.com', timeout=5)
|
||||
23 | requests.head('https://gmail.com')
|
||||
| ^^^^^^^^^^^^^ S113
|
||||
24 | requests.head('https://gmail.com', timeout=None)
|
||||
25 | requests.head('https://gmail.com', timeout=5)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S113.py:22:44: S113 Probable use of requests call with timeout set to `None`
|
||||
|
|
||||
22 | requests.options('https://gmail.com', timeout=5)
|
||||
23 | requests.head('https://gmail.com')
|
||||
24 | requests.head('https://gmail.com', timeout=None)
|
||||
| ^^^^ S113
|
||||
25 | requests.head('https://gmail.com', timeout=5)
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,19 +1,12 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: SuspiciousPickleUsage
|
||||
body: "`pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 3
|
||||
column: 0
|
||||
end_location:
|
||||
row: 3
|
||||
column: 14
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S301.py:3:1: S301 `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue
|
||||
|
|
||||
3 | import pickle
|
||||
4 |
|
||||
5 | pickle.loads()
|
||||
| ^^^^^^^^^^^^^^ S301
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,19 +1,12 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: SuspiciousTelnetUsage
|
||||
body: Telnet-related functions are being called. Telnet is considered insecure. Use SSH or some other encrypted protocol.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 3
|
||||
column: 0
|
||||
end_location:
|
||||
row: 3
|
||||
column: 23
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S312.py:3:1: S312 Telnet-related functions are being called. Telnet is considered insecure. Use SSH or some other encrypted protocol.
|
||||
|
|
||||
3 | from telnetlib import Telnet
|
||||
4 |
|
||||
5 | Telnet("localhost", 23)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ S312
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,187 +1,133 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: HashlibInsecureHashFunction
|
||||
body: "Probable use of insecure hash functions in `hashlib`: `md5`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 7
|
||||
column: 12
|
||||
end_location:
|
||||
row: 7
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HashlibInsecureHashFunction
|
||||
body: "Probable use of insecure hash functions in `hashlib`: `md4`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 9
|
||||
column: 12
|
||||
end_location:
|
||||
row: 9
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HashlibInsecureHashFunction
|
||||
body: "Probable use of insecure hash functions in `hashlib`: `md5`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 11
|
||||
column: 17
|
||||
end_location:
|
||||
row: 11
|
||||
column: 22
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HashlibInsecureHashFunction
|
||||
body: "Probable use of insecure hash functions in `hashlib`: `MD4`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 12
|
||||
end_location:
|
||||
row: 13
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HashlibInsecureHashFunction
|
||||
body: "Probable use of insecure hash functions in `hashlib`: `sha1`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 15
|
||||
column: 12
|
||||
end_location:
|
||||
row: 15
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HashlibInsecureHashFunction
|
||||
body: "Probable use of insecure hash functions in `hashlib`: `sha1`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 17
|
||||
column: 12
|
||||
end_location:
|
||||
row: 17
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HashlibInsecureHashFunction
|
||||
body: "Probable use of insecure hash functions in `hashlib`: `sha`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 19
|
||||
column: 12
|
||||
end_location:
|
||||
row: 19
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HashlibInsecureHashFunction
|
||||
body: "Probable use of insecure hash functions in `hashlib`: `SHA`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 21
|
||||
column: 17
|
||||
end_location:
|
||||
row: 21
|
||||
column: 22
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HashlibInsecureHashFunction
|
||||
body: "Probable use of insecure hash functions in `hashlib`: `sha`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 23
|
||||
column: 0
|
||||
end_location:
|
||||
row: 23
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HashlibInsecureHashFunction
|
||||
body: "Probable use of insecure hash functions in `hashlib`: `md5`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 25
|
||||
column: 0
|
||||
end_location:
|
||||
row: 25
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HashlibInsecureHashFunction
|
||||
body: "Probable use of insecure hash functions in `hashlib`: `sha1`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 27
|
||||
column: 12
|
||||
end_location:
|
||||
row: 27
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HashlibInsecureHashFunction
|
||||
body: "Probable use of insecure hash functions in `hashlib`: `sha1`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 29
|
||||
column: 0
|
||||
end_location:
|
||||
row: 29
|
||||
column: 12
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: HashlibInsecureHashFunction
|
||||
body: "Probable use of insecure hash functions in `hashlib`: `sha1`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 32
|
||||
column: 12
|
||||
end_location:
|
||||
row: 32
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S324.py:7:13: S324 Probable use of insecure hash functions in `hashlib`: `md5`
|
||||
|
|
||||
7 | # Invalid
|
||||
8 |
|
||||
9 | hashlib.new('md5')
|
||||
| ^^^^^ S324
|
||||
10 |
|
||||
11 | hashlib.new('md4', b'test')
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S324.py:9:13: S324 Probable use of insecure hash functions in `hashlib`: `md4`
|
||||
|
|
||||
9 | hashlib.new('md5')
|
||||
10 |
|
||||
11 | hashlib.new('md4', b'test')
|
||||
| ^^^^^ S324
|
||||
12 |
|
||||
13 | hashlib.new(name='md5', data=b'test')
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S324.py:11:18: S324 Probable use of insecure hash functions in `hashlib`: `md5`
|
||||
|
|
||||
11 | hashlib.new('md4', b'test')
|
||||
12 |
|
||||
13 | hashlib.new(name='md5', data=b'test')
|
||||
| ^^^^^ S324
|
||||
14 |
|
||||
15 | hashlib.new('MD4', data=b'test')
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S324.py:13:13: S324 Probable use of insecure hash functions in `hashlib`: `MD4`
|
||||
|
|
||||
13 | hashlib.new(name='md5', data=b'test')
|
||||
14 |
|
||||
15 | hashlib.new('MD4', data=b'test')
|
||||
| ^^^^^ S324
|
||||
16 |
|
||||
17 | hashlib.new('sha1')
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S324.py:15:13: S324 Probable use of insecure hash functions in `hashlib`: `sha1`
|
||||
|
|
||||
15 | hashlib.new('MD4', data=b'test')
|
||||
16 |
|
||||
17 | hashlib.new('sha1')
|
||||
| ^^^^^^ S324
|
||||
18 |
|
||||
19 | hashlib.new('sha1', data=b'test')
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S324.py:17:13: S324 Probable use of insecure hash functions in `hashlib`: `sha1`
|
||||
|
|
||||
17 | hashlib.new('sha1')
|
||||
18 |
|
||||
19 | hashlib.new('sha1', data=b'test')
|
||||
| ^^^^^^ S324
|
||||
20 |
|
||||
21 | hashlib.new('sha', data=b'test')
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S324.py:19:13: S324 Probable use of insecure hash functions in `hashlib`: `sha`
|
||||
|
|
||||
19 | hashlib.new('sha1', data=b'test')
|
||||
20 |
|
||||
21 | hashlib.new('sha', data=b'test')
|
||||
| ^^^^^ S324
|
||||
22 |
|
||||
23 | hashlib.new(name='SHA', data=b'test')
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S324.py:21:18: S324 Probable use of insecure hash functions in `hashlib`: `SHA`
|
||||
|
|
||||
21 | hashlib.new('sha', data=b'test')
|
||||
22 |
|
||||
23 | hashlib.new(name='SHA', data=b'test')
|
||||
| ^^^^^ S324
|
||||
24 |
|
||||
25 | hashlib.sha(data=b'test')
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S324.py:23:1: S324 Probable use of insecure hash functions in `hashlib`: `sha`
|
||||
|
|
||||
23 | hashlib.new(name='SHA', data=b'test')
|
||||
24 |
|
||||
25 | hashlib.sha(data=b'test')
|
||||
| ^^^^^^^^^^^ S324
|
||||
26 |
|
||||
27 | hashlib.md5()
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S324.py:25:1: S324 Probable use of insecure hash functions in `hashlib`: `md5`
|
||||
|
|
||||
25 | hashlib.sha(data=b'test')
|
||||
26 |
|
||||
27 | hashlib.md5()
|
||||
| ^^^^^^^^^^^ S324
|
||||
28 |
|
||||
29 | hashlib_new('sha1')
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S324.py:27:13: S324 Probable use of insecure hash functions in `hashlib`: `sha1`
|
||||
|
|
||||
27 | hashlib.md5()
|
||||
28 |
|
||||
29 | hashlib_new('sha1')
|
||||
| ^^^^^^ S324
|
||||
30 |
|
||||
31 | hashlib_sha1('sha1')
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S324.py:29:1: S324 Probable use of insecure hash functions in `hashlib`: `sha1`
|
||||
|
|
||||
29 | hashlib_new('sha1')
|
||||
30 |
|
||||
31 | hashlib_sha1('sha1')
|
||||
| ^^^^^^^^^^^^ S324
|
||||
32 |
|
||||
33 | # usedforsecurity arg only available in Python 3.9+
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S324.py:32:13: S324 Probable use of insecure hash functions in `hashlib`: `sha1`
|
||||
|
|
||||
32 | # usedforsecurity arg only available in Python 3.9+
|
||||
33 | hashlib.new('sha1', usedforsecurity=True)
|
||||
| ^^^^^^ S324
|
||||
34 |
|
||||
35 | # Valid
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,257 +1,180 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: RequestWithNoCertValidation
|
||||
body: "Probable use of `requests` call with `verify=False` disabling SSL certificate checks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 53
|
||||
end_location:
|
||||
row: 5
|
||||
column: 58
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithNoCertValidation
|
||||
body: "Probable use of `requests` call with `verify=False` disabling SSL certificate checks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 7
|
||||
column: 54
|
||||
end_location:
|
||||
row: 7
|
||||
column: 59
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithNoCertValidation
|
||||
body: "Probable use of `requests` call with `verify=False` disabling SSL certificate checks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 9
|
||||
column: 53
|
||||
end_location:
|
||||
row: 9
|
||||
column: 58
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithNoCertValidation
|
||||
body: "Probable use of `requests` call with `verify=False` disabling SSL certificate checks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 11
|
||||
column: 56
|
||||
end_location:
|
||||
row: 11
|
||||
column: 61
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithNoCertValidation
|
||||
body: "Probable use of `requests` call with `verify=False` disabling SSL certificate checks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 55
|
||||
end_location:
|
||||
row: 13
|
||||
column: 60
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithNoCertValidation
|
||||
body: "Probable use of `requests` call with `verify=False` disabling SSL certificate checks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 15
|
||||
column: 57
|
||||
end_location:
|
||||
row: 15
|
||||
column: 62
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithNoCertValidation
|
||||
body: "Probable use of `requests` call with `verify=False` disabling SSL certificate checks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 17
|
||||
column: 54
|
||||
end_location:
|
||||
row: 17
|
||||
column: 59
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithNoCertValidation
|
||||
body: "Probable use of `httpx` call with `verify=False` disabling SSL certificate checks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 20
|
||||
column: 49
|
||||
end_location:
|
||||
row: 20
|
||||
column: 54
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithNoCertValidation
|
||||
body: "Probable use of `httpx` call with `verify=False` disabling SSL certificate checks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 22
|
||||
column: 38
|
||||
end_location:
|
||||
row: 22
|
||||
column: 43
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithNoCertValidation
|
||||
body: "Probable use of `httpx` call with `verify=False` disabling SSL certificate checks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 24
|
||||
column: 42
|
||||
end_location:
|
||||
row: 24
|
||||
column: 47
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithNoCertValidation
|
||||
body: "Probable use of `httpx` call with `verify=False` disabling SSL certificate checks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 26
|
||||
column: 39
|
||||
end_location:
|
||||
row: 26
|
||||
column: 44
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithNoCertValidation
|
||||
body: "Probable use of `httpx` call with `verify=False` disabling SSL certificate checks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 28
|
||||
column: 39
|
||||
end_location:
|
||||
row: 28
|
||||
column: 44
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithNoCertValidation
|
||||
body: "Probable use of `httpx` call with `verify=False` disabling SSL certificate checks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 30
|
||||
column: 38
|
||||
end_location:
|
||||
row: 30
|
||||
column: 43
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithNoCertValidation
|
||||
body: "Probable use of `httpx` call with `verify=False` disabling SSL certificate checks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 32
|
||||
column: 40
|
||||
end_location:
|
||||
row: 32
|
||||
column: 45
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithNoCertValidation
|
||||
body: "Probable use of `httpx` call with `verify=False` disabling SSL certificate checks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 34
|
||||
column: 41
|
||||
end_location:
|
||||
row: 34
|
||||
column: 46
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithNoCertValidation
|
||||
body: "Probable use of `httpx` call with `verify=False` disabling SSL certificate checks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 36
|
||||
column: 41
|
||||
end_location:
|
||||
row: 36
|
||||
column: 46
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithNoCertValidation
|
||||
body: "Probable use of `httpx` call with `verify=False` disabling SSL certificate checks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 38
|
||||
column: 20
|
||||
end_location:
|
||||
row: 38
|
||||
column: 25
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RequestWithNoCertValidation
|
||||
body: "Probable use of `httpx` call with `verify=False` disabling SSL certificate checks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 40
|
||||
column: 25
|
||||
end_location:
|
||||
row: 40
|
||||
column: 30
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S501.py:5:54: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks
|
||||
|
|
||||
5 | requests.get('https://gmail.com', timeout=30, verify=True)
|
||||
6 | requests.get('https://gmail.com', timeout=30, verify=False)
|
||||
| ^^^^^ S501
|
||||
7 | requests.post('https://gmail.com', timeout=30, verify=True)
|
||||
8 | requests.post('https://gmail.com', timeout=30, verify=False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S501.py:7:55: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks
|
||||
|
|
||||
7 | requests.get('https://gmail.com', timeout=30, verify=False)
|
||||
8 | requests.post('https://gmail.com', timeout=30, verify=True)
|
||||
9 | requests.post('https://gmail.com', timeout=30, verify=False)
|
||||
| ^^^^^ S501
|
||||
10 | requests.put('https://gmail.com', timeout=30, verify=True)
|
||||
11 | requests.put('https://gmail.com', timeout=30, verify=False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S501.py:9:54: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks
|
||||
|
|
||||
9 | requests.post('https://gmail.com', timeout=30, verify=False)
|
||||
10 | requests.put('https://gmail.com', timeout=30, verify=True)
|
||||
11 | requests.put('https://gmail.com', timeout=30, verify=False)
|
||||
| ^^^^^ S501
|
||||
12 | requests.delete('https://gmail.com', timeout=30, verify=True)
|
||||
13 | requests.delete('https://gmail.com', timeout=30, verify=False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S501.py:11:57: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks
|
||||
|
|
||||
11 | requests.put('https://gmail.com', timeout=30, verify=False)
|
||||
12 | requests.delete('https://gmail.com', timeout=30, verify=True)
|
||||
13 | requests.delete('https://gmail.com', timeout=30, verify=False)
|
||||
| ^^^^^ S501
|
||||
14 | requests.patch('https://gmail.com', timeout=30, verify=True)
|
||||
15 | requests.patch('https://gmail.com', timeout=30, verify=False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S501.py:13:56: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks
|
||||
|
|
||||
13 | requests.delete('https://gmail.com', timeout=30, verify=False)
|
||||
14 | requests.patch('https://gmail.com', timeout=30, verify=True)
|
||||
15 | requests.patch('https://gmail.com', timeout=30, verify=False)
|
||||
| ^^^^^ S501
|
||||
16 | requests.options('https://gmail.com', timeout=30, verify=True)
|
||||
17 | requests.options('https://gmail.com', timeout=30, verify=False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S501.py:15:58: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks
|
||||
|
|
||||
15 | requests.patch('https://gmail.com', timeout=30, verify=False)
|
||||
16 | requests.options('https://gmail.com', timeout=30, verify=True)
|
||||
17 | requests.options('https://gmail.com', timeout=30, verify=False)
|
||||
| ^^^^^ S501
|
||||
18 | requests.head('https://gmail.com', timeout=30, verify=True)
|
||||
19 | requests.head('https://gmail.com', timeout=30, verify=False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S501.py:17:55: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks
|
||||
|
|
||||
17 | requests.options('https://gmail.com', timeout=30, verify=False)
|
||||
18 | requests.head('https://gmail.com', timeout=30, verify=True)
|
||||
19 | requests.head('https://gmail.com', timeout=30, verify=False)
|
||||
| ^^^^^ S501
|
||||
20 |
|
||||
21 | httpx.request('GET', 'https://gmail.com', verify=True)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S501.py:20:50: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks
|
||||
|
|
||||
20 | httpx.request('GET', 'https://gmail.com', verify=True)
|
||||
21 | httpx.request('GET', 'https://gmail.com', verify=False)
|
||||
| ^^^^^ S501
|
||||
22 | httpx.get('https://gmail.com', verify=True)
|
||||
23 | httpx.get('https://gmail.com', verify=False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S501.py:22:39: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks
|
||||
|
|
||||
22 | httpx.request('GET', 'https://gmail.com', verify=False)
|
||||
23 | httpx.get('https://gmail.com', verify=True)
|
||||
24 | httpx.get('https://gmail.com', verify=False)
|
||||
| ^^^^^ S501
|
||||
25 | httpx.options('https://gmail.com', verify=True)
|
||||
26 | httpx.options('https://gmail.com', verify=False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S501.py:24:43: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks
|
||||
|
|
||||
24 | httpx.get('https://gmail.com', verify=False)
|
||||
25 | httpx.options('https://gmail.com', verify=True)
|
||||
26 | httpx.options('https://gmail.com', verify=False)
|
||||
| ^^^^^ S501
|
||||
27 | httpx.head('https://gmail.com', verify=True)
|
||||
28 | httpx.head('https://gmail.com', verify=False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S501.py:26:40: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks
|
||||
|
|
||||
26 | httpx.options('https://gmail.com', verify=False)
|
||||
27 | httpx.head('https://gmail.com', verify=True)
|
||||
28 | httpx.head('https://gmail.com', verify=False)
|
||||
| ^^^^^ S501
|
||||
29 | httpx.post('https://gmail.com', verify=True)
|
||||
30 | httpx.post('https://gmail.com', verify=False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S501.py:28:40: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks
|
||||
|
|
||||
28 | httpx.head('https://gmail.com', verify=False)
|
||||
29 | httpx.post('https://gmail.com', verify=True)
|
||||
30 | httpx.post('https://gmail.com', verify=False)
|
||||
| ^^^^^ S501
|
||||
31 | httpx.put('https://gmail.com', verify=True)
|
||||
32 | httpx.put('https://gmail.com', verify=False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S501.py:30:39: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks
|
||||
|
|
||||
30 | httpx.post('https://gmail.com', verify=False)
|
||||
31 | httpx.put('https://gmail.com', verify=True)
|
||||
32 | httpx.put('https://gmail.com', verify=False)
|
||||
| ^^^^^ S501
|
||||
33 | httpx.patch('https://gmail.com', verify=True)
|
||||
34 | httpx.patch('https://gmail.com', verify=False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S501.py:32:41: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks
|
||||
|
|
||||
32 | httpx.put('https://gmail.com', verify=False)
|
||||
33 | httpx.patch('https://gmail.com', verify=True)
|
||||
34 | httpx.patch('https://gmail.com', verify=False)
|
||||
| ^^^^^ S501
|
||||
35 | httpx.delete('https://gmail.com', verify=True)
|
||||
36 | httpx.delete('https://gmail.com', verify=False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S501.py:34:42: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks
|
||||
|
|
||||
34 | httpx.patch('https://gmail.com', verify=False)
|
||||
35 | httpx.delete('https://gmail.com', verify=True)
|
||||
36 | httpx.delete('https://gmail.com', verify=False)
|
||||
| ^^^^^ S501
|
||||
37 | httpx.stream('https://gmail.com', verify=True)
|
||||
38 | httpx.stream('https://gmail.com', verify=False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S501.py:36:42: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks
|
||||
|
|
||||
36 | httpx.delete('https://gmail.com', verify=False)
|
||||
37 | httpx.stream('https://gmail.com', verify=True)
|
||||
38 | httpx.stream('https://gmail.com', verify=False)
|
||||
| ^^^^^ S501
|
||||
39 | httpx.Client()
|
||||
40 | httpx.Client(verify=False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S501.py:38:21: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks
|
||||
|
|
||||
38 | httpx.stream('https://gmail.com', verify=False)
|
||||
39 | httpx.Client()
|
||||
40 | httpx.Client(verify=False)
|
||||
| ^^^^^ S501
|
||||
41 | httpx.AsyncClient()
|
||||
42 | httpx.AsyncClient(verify=False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S501.py:40:26: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks
|
||||
|
|
||||
40 | httpx.Client(verify=False)
|
||||
41 | httpx.AsyncClient()
|
||||
42 | httpx.AsyncClient(verify=False)
|
||||
| ^^^^^ S501
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,33 +1,22 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: UnsafeYAMLLoad
|
||||
body: "Probable use of unsafe `yaml.load`. Allows instantiation of arbitrary objects. Consider `yaml.safe_load`."
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 10
|
||||
column: 8
|
||||
end_location:
|
||||
row: 10
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnsafeYAMLLoad
|
||||
body: "Probable use of unsafe loader `Loader` with `yaml.load`. Allows instantiation of arbitrary objects. Consider `yaml.safe_load`."
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 24
|
||||
column: 23
|
||||
end_location:
|
||||
row: 24
|
||||
column: 34
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S506.py:10:9: S506 Probable use of unsafe `yaml.load`. Allows instantiation of arbitrary objects. Consider `yaml.safe_load`.
|
||||
|
|
||||
10 | def test_yaml_load():
|
||||
11 | ystr = yaml.dump({"a": 1, "b": 2, "c": 3})
|
||||
12 | y = yaml.load(ystr)
|
||||
| ^^^^^^^^^ S506
|
||||
13 | yaml.dump(y)
|
||||
14 | try:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S506.py:24:24: S506 Probable use of unsafe loader `Loader` with `yaml.load`. Allows instantiation of arbitrary objects. Consider `yaml.safe_load`.
|
||||
|
|
||||
24 | yaml.load("{}", Loader=yaml.Loader)
|
||||
| ^^^^^^^^^^^ S506
|
||||
25 |
|
||||
26 | # no issue should be found
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,33 +1,22 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: SnmpInsecureVersion
|
||||
body: The use of SNMPv1 and SNMPv2 is insecure. Use SNMPv3 if able.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 3
|
||||
column: 32
|
||||
end_location:
|
||||
row: 3
|
||||
column: 33
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SnmpInsecureVersion
|
||||
body: The use of SNMPv1 and SNMPv2 is insecure. Use SNMPv3 if able.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 32
|
||||
end_location:
|
||||
row: 4
|
||||
column: 33
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S508.py:3:33: S508 The use of SNMPv1 and SNMPv2 is insecure. Use SNMPv3 if able.
|
||||
|
|
||||
3 | from pysnmp.hlapi import CommunityData
|
||||
4 |
|
||||
5 | CommunityData("public", mpModel=0) # S508
|
||||
| ^ S508
|
||||
6 | CommunityData("public", mpModel=1) # S508
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S508.py:4:33: S508 The use of SNMPv1 and SNMPv2 is insecure. Use SNMPv3 if able.
|
||||
|
|
||||
4 | CommunityData("public", mpModel=0) # S508
|
||||
5 | CommunityData("public", mpModel=1) # S508
|
||||
| ^ S508
|
||||
6 |
|
||||
7 | CommunityData("public", mpModel=2) # OK
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,33 +1,20 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: SnmpWeakCryptography
|
||||
body: "You should not use SNMPv3 without encryption. `noAuthNoPriv` & `authNoPriv` is insecure."
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 11
|
||||
end_location:
|
||||
row: 4
|
||||
column: 22
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SnmpWeakCryptography
|
||||
body: "You should not use SNMPv3 without encryption. `noAuthNoPriv` & `authNoPriv` is insecure."
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 15
|
||||
end_location:
|
||||
row: 5
|
||||
column: 26
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S509.py:4:12: S509 You should not use SNMPv3 without encryption. `noAuthNoPriv` & `authNoPriv` is insecure.
|
||||
|
|
||||
4 | insecure = UsmUserData("securityName") # S509
|
||||
| ^^^^^^^^^^^ S509
|
||||
5 | auth_no_priv = UsmUserData("securityName", "authName") # S509
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S509.py:5:16: S509 You should not use SNMPv3 without encryption. `noAuthNoPriv` & `authNoPriv` is insecure.
|
||||
|
|
||||
5 | insecure = UsmUserData("securityName") # S509
|
||||
6 | auth_no_priv = UsmUserData("securityName", "authName") # S509
|
||||
| ^^^^^^^^^^^ S509
|
||||
7 |
|
||||
8 | less_insecure = UsmUserData("securityName", "authName", "privName") # OK
|
||||
|
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,19 +1,14 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: LoggingConfigInsecureListen
|
||||
body: "Use of insecure `logging.config.listen` detected"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 3
|
||||
column: 4
|
||||
end_location:
|
||||
row: 3
|
||||
column: 25
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S612.py:3:5: S612 Use of insecure `logging.config.listen` detected
|
||||
|
|
||||
3 | import logging.config
|
||||
4 |
|
||||
5 | t = logging.config.listen(9999)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ S612
|
||||
6 |
|
||||
7 | def verify_func():
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,75 +1,51 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: Jinja2AutoescapeFalse
|
||||
body: "Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function."
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 9
|
||||
column: 67
|
||||
end_location:
|
||||
row: 9
|
||||
column: 76
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: Jinja2AutoescapeFalse
|
||||
body: "Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function."
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 10
|
||||
column: 44
|
||||
end_location:
|
||||
row: 10
|
||||
column: 49
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: Jinja2AutoescapeFalse
|
||||
body: "Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function."
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 23
|
||||
end_location:
|
||||
row: 13
|
||||
column: 28
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: Jinja2AutoescapeFalse
|
||||
body: "By default, jinja2 sets `autoescape` to `False`. Consider using `autoescape=True` or the `select_autoescape` function to mitigate XSS vulnerabilities."
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 15
|
||||
column: 0
|
||||
end_location:
|
||||
row: 15
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: Jinja2AutoescapeFalse
|
||||
body: "Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function."
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 29
|
||||
column: 46
|
||||
end_location:
|
||||
row: 29
|
||||
column: 57
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bandit/S701.py:9:68: S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function.
|
||||
|
|
||||
9 | templateEnv = jinja2.Environment(autoescape=True,
|
||||
10 | loader=templateLoader )
|
||||
11 | Environment(loader=templateLoader, load=templateLoader, autoescape=something) # S701
|
||||
| ^^^^^^^^^ S701
|
||||
12 | templateEnv = jinja2.Environment(autoescape=False, loader=templateLoader ) # S701
|
||||
13 | Environment(loader=templateLoader,
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S701.py:10:45: S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function.
|
||||
|
|
||||
10 | loader=templateLoader )
|
||||
11 | Environment(loader=templateLoader, load=templateLoader, autoescape=something) # S701
|
||||
12 | templateEnv = jinja2.Environment(autoescape=False, loader=templateLoader ) # S701
|
||||
| ^^^^^ S701
|
||||
13 | Environment(loader=templateLoader,
|
||||
14 | load=templateLoader,
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S701.py:13:24: S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function.
|
||||
|
|
||||
13 | Environment(loader=templateLoader,
|
||||
14 | load=templateLoader,
|
||||
15 | autoescape=False) # S701
|
||||
| ^^^^^ S701
|
||||
16 |
|
||||
17 | Environment(loader=templateLoader, # S701
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S701.py:15:1: S701 By default, jinja2 sets `autoescape` to `False`. Consider using `autoescape=True` or the `select_autoescape` function to mitigate XSS vulnerabilities.
|
||||
|
|
||||
15 | autoescape=False) # S701
|
||||
16 |
|
||||
17 | Environment(loader=templateLoader, # S701
|
||||
| ^^^^^^^^^^^ S701
|
||||
18 | load=templateLoader)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bandit/S701.py:29:47: S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function.
|
||||
|
|
||||
29 | def fake_func():
|
||||
30 | return 'foobar'
|
||||
31 | Environment(loader=templateLoader, autoescape=fake_func()) # S701
|
||||
| ^^^^^^^^^^^ S701
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@ mod tests {
|
|||
use std::path::Path;
|
||||
|
||||
use anyhow::Result;
|
||||
use insta::assert_yaml_snapshot;
|
||||
|
||||
use test_case::test_case;
|
||||
|
||||
use crate::registry::Rule;
|
||||
use crate::settings;
|
||||
use crate::test::test_path;
|
||||
use crate::{assert_messages, settings};
|
||||
|
||||
#[test_case(Rule::BlindExcept, Path::new("BLE.py"); "BLE001")]
|
||||
fn rules(rule_code: Rule, path: &Path) -> Result<()> {
|
||||
|
@ -20,7 +20,7 @@ mod tests {
|
|||
Path::new("flake8_blind_except").join(path).as_path(),
|
||||
&settings::Settings::for_rule(rule_code),
|
||||
)?;
|
||||
assert_yaml_snapshot!(snapshot, diagnostics);
|
||||
assert_messages!(snapshot, diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,145 +1,97 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_blind_except/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: BlindExcept
|
||||
body: "Do not catch blind exception: `BaseException`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 25
|
||||
column: 7
|
||||
end_location:
|
||||
row: 25
|
||||
column: 20
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BlindExcept
|
||||
body: "Do not catch blind exception: `Exception`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 31
|
||||
column: 7
|
||||
end_location:
|
||||
row: 31
|
||||
column: 16
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BlindExcept
|
||||
body: "Do not catch blind exception: `Exception`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 42
|
||||
column: 7
|
||||
end_location:
|
||||
row: 42
|
||||
column: 16
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BlindExcept
|
||||
body: "Do not catch blind exception: `BaseException`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 45
|
||||
column: 11
|
||||
end_location:
|
||||
row: 45
|
||||
column: 24
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BlindExcept
|
||||
body: "Do not catch blind exception: `Exception`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 54
|
||||
column: 7
|
||||
end_location:
|
||||
row: 54
|
||||
column: 16
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BlindExcept
|
||||
body: "Do not catch blind exception: `Exception`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 60
|
||||
column: 7
|
||||
end_location:
|
||||
row: 60
|
||||
column: 16
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BlindExcept
|
||||
body: "Do not catch blind exception: `BaseException`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 62
|
||||
column: 7
|
||||
end_location:
|
||||
row: 62
|
||||
column: 20
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BlindExcept
|
||||
body: "Do not catch blind exception: `Exception`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 69
|
||||
column: 7
|
||||
end_location:
|
||||
row: 69
|
||||
column: 16
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BlindExcept
|
||||
body: "Do not catch blind exception: `Exception`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 75
|
||||
column: 7
|
||||
end_location:
|
||||
row: 75
|
||||
column: 16
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BlindExcept
|
||||
body: "Do not catch blind exception: `Exception`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 81
|
||||
column: 7
|
||||
end_location:
|
||||
row: 81
|
||||
column: 16
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_blind_except/BLE.py:25:8: BLE001 Do not catch blind exception: `BaseException`
|
||||
|
|
||||
25 | except Exception as e:
|
||||
26 | raise e
|
||||
27 | except BaseException:
|
||||
| ^^^^^^^^^^^^^ BLE001
|
||||
28 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_blind_except/BLE.py:31:8: BLE001 Do not catch blind exception: `Exception`
|
||||
|
|
||||
31 | try:
|
||||
32 | pass
|
||||
33 | except Exception:
|
||||
| ^^^^^^^^^ BLE001
|
||||
34 | pass
|
||||
35 | finally:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_blind_except/BLE.py:42:8: BLE001 Do not catch blind exception: `Exception`
|
||||
|
|
||||
42 | try:
|
||||
43 | pass
|
||||
44 | except Exception as e:
|
||||
| ^^^^^^^^^ BLE001
|
||||
45 | try:
|
||||
46 | raise e
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_blind_except/BLE.py:45:12: BLE001 Do not catch blind exception: `BaseException`
|
||||
|
|
||||
45 | try:
|
||||
46 | raise e
|
||||
47 | except BaseException:
|
||||
| ^^^^^^^^^^^^^ BLE001
|
||||
48 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_blind_except/BLE.py:54:8: BLE001 Do not catch blind exception: `Exception`
|
||||
|
|
||||
54 | except BaseException as e:
|
||||
55 | raise e
|
||||
56 | except Exception:
|
||||
| ^^^^^^^^^ BLE001
|
||||
57 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_blind_except/BLE.py:60:8: BLE001 Do not catch blind exception: `Exception`
|
||||
|
|
||||
60 | try:
|
||||
61 | pass
|
||||
62 | except Exception as e:
|
||||
| ^^^^^^^^^ BLE001
|
||||
63 | raise bad
|
||||
64 | except BaseException:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_blind_except/BLE.py:62:8: BLE001 Do not catch blind exception: `BaseException`
|
||||
|
|
||||
62 | except Exception as e:
|
||||
63 | raise bad
|
||||
64 | except BaseException:
|
||||
| ^^^^^^^^^^^^^ BLE001
|
||||
65 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_blind_except/BLE.py:69:8: BLE001 Do not catch blind exception: `Exception`
|
||||
|
|
||||
69 | try:
|
||||
70 | pass
|
||||
71 | except Exception:
|
||||
| ^^^^^^^^^ BLE001
|
||||
72 | logging.error("...")
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_blind_except/BLE.py:75:8: BLE001 Do not catch blind exception: `Exception`
|
||||
|
|
||||
75 | try:
|
||||
76 | pass
|
||||
77 | except Exception:
|
||||
| ^^^^^^^^^ BLE001
|
||||
78 | logging.error("...", exc_info=False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_blind_except/BLE.py:81:8: BLE001 Do not catch blind exception: `Exception`
|
||||
|
|
||||
81 | try:
|
||||
82 | pass
|
||||
83 | except Exception:
|
||||
| ^^^^^^^^^ BLE001
|
||||
84 | logging.error("...", exc_info=None)
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@ mod tests {
|
|||
use std::path::Path;
|
||||
|
||||
use anyhow::Result;
|
||||
use insta::assert_yaml_snapshot;
|
||||
|
||||
use test_case::test_case;
|
||||
|
||||
use crate::registry::Rule;
|
||||
use crate::settings;
|
||||
use crate::test::test_path;
|
||||
use crate::{assert_messages, settings};
|
||||
|
||||
#[test_case(Rule::BooleanPositionalArgInFunctionDefinition, Path::new("FBT.py"); "FBT001")]
|
||||
#[test_case(Rule::BooleanDefaultValueInFunctionDefinition, Path::new("FBT.py"); "FBT002")]
|
||||
|
@ -22,7 +22,7 @@ mod tests {
|
|||
Path::new("flake8_boolean_trap").join(path).as_path(),
|
||||
&settings::Settings::for_rule(rule_code),
|
||||
)?;
|
||||
assert_yaml_snapshot!(snapshot, diagnostics);
|
||||
assert_messages!(snapshot, diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,131 +1,92 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_boolean_trap/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: BooleanPositionalArgInFunctionDefinition
|
||||
body: Boolean positional arg in function definition
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 4
|
||||
end_location:
|
||||
row: 4
|
||||
column: 26
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BooleanPositionalArgInFunctionDefinition
|
||||
body: Boolean positional arg in function definition
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 4
|
||||
end_location:
|
||||
row: 5
|
||||
column: 31
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BooleanPositionalArgInFunctionDefinition
|
||||
body: Boolean positional arg in function definition
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 10
|
||||
column: 4
|
||||
end_location:
|
||||
row: 10
|
||||
column: 36
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BooleanPositionalArgInFunctionDefinition
|
||||
body: Boolean positional arg in function definition
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 11
|
||||
column: 4
|
||||
end_location:
|
||||
row: 11
|
||||
column: 41
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BooleanPositionalArgInFunctionDefinition
|
||||
body: Boolean positional arg in function definition
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 14
|
||||
column: 4
|
||||
end_location:
|
||||
row: 14
|
||||
column: 37
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BooleanPositionalArgInFunctionDefinition
|
||||
body: Boolean positional arg in function definition
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 15
|
||||
column: 4
|
||||
end_location:
|
||||
row: 15
|
||||
column: 42
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BooleanPositionalArgInFunctionDefinition
|
||||
body: Boolean positional arg in function definition
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 18
|
||||
column: 4
|
||||
end_location:
|
||||
row: 18
|
||||
column: 40
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BooleanPositionalArgInFunctionDefinition
|
||||
body: Boolean positional arg in function definition
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 19
|
||||
column: 4
|
||||
end_location:
|
||||
row: 19
|
||||
column: 45
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BooleanPositionalArgInFunctionDefinition
|
||||
body: Boolean positional arg in function definition
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 81
|
||||
column: 18
|
||||
end_location:
|
||||
row: 81
|
||||
column: 29
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_boolean_trap/FBT.py:4:5: FBT001 Boolean positional arg in function definition
|
||||
|
|
||||
4 | posonly_nohint,
|
||||
5 | posonly_nonboolhint: int,
|
||||
6 | posonly_boolhint: bool,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ FBT001
|
||||
7 | posonly_boolstrhint: "bool",
|
||||
8 | /,
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_boolean_trap/FBT.py:5:5: FBT001 Boolean positional arg in function definition
|
||||
|
|
||||
5 | posonly_nonboolhint: int,
|
||||
6 | posonly_boolhint: bool,
|
||||
7 | posonly_boolstrhint: "bool",
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001
|
||||
8 | /,
|
||||
9 | offset,
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_boolean_trap/FBT.py:10:5: FBT001 Boolean positional arg in function definition
|
||||
|
|
||||
10 | posorkw_nonvalued_nohint,
|
||||
11 | posorkw_nonvalued_nonboolhint: int,
|
||||
12 | posorkw_nonvalued_boolhint: bool,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001
|
||||
13 | posorkw_nonvalued_boolstrhint: "bool",
|
||||
14 | posorkw_boolvalued_nohint=True,
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_boolean_trap/FBT.py:11:5: FBT001 Boolean positional arg in function definition
|
||||
|
|
||||
11 | posorkw_nonvalued_nonboolhint: int,
|
||||
12 | posorkw_nonvalued_boolhint: bool,
|
||||
13 | posorkw_nonvalued_boolstrhint: "bool",
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001
|
||||
14 | posorkw_boolvalued_nohint=True,
|
||||
15 | posorkw_boolvalued_nonboolhint: int = True,
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_boolean_trap/FBT.py:14:5: FBT001 Boolean positional arg in function definition
|
||||
|
|
||||
14 | posorkw_boolvalued_nohint=True,
|
||||
15 | posorkw_boolvalued_nonboolhint: int = True,
|
||||
16 | posorkw_boolvalued_boolhint: bool = True,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001
|
||||
17 | posorkw_boolvalued_boolstrhint: "bool" = True,
|
||||
18 | posorkw_nonboolvalued_nohint=1,
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_boolean_trap/FBT.py:15:5: FBT001 Boolean positional arg in function definition
|
||||
|
|
||||
15 | posorkw_boolvalued_nonboolhint: int = True,
|
||||
16 | posorkw_boolvalued_boolhint: bool = True,
|
||||
17 | posorkw_boolvalued_boolstrhint: "bool" = True,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001
|
||||
18 | posorkw_nonboolvalued_nohint=1,
|
||||
19 | posorkw_nonboolvalued_nonboolhint: int = 2,
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_boolean_trap/FBT.py:18:5: FBT001 Boolean positional arg in function definition
|
||||
|
|
||||
18 | posorkw_nonboolvalued_nohint=1,
|
||||
19 | posorkw_nonboolvalued_nonboolhint: int = 2,
|
||||
20 | posorkw_nonboolvalued_boolhint: bool = 3,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001
|
||||
21 | posorkw_nonboolvalued_boolstrhint: "bool" = 4,
|
||||
22 | *,
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_boolean_trap/FBT.py:19:5: FBT001 Boolean positional arg in function definition
|
||||
|
|
||||
19 | posorkw_nonboolvalued_nonboolhint: int = 2,
|
||||
20 | posorkw_nonboolvalued_boolhint: bool = 3,
|
||||
21 | posorkw_nonboolvalued_boolstrhint: "bool" = 4,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001
|
||||
22 | *,
|
||||
23 | kwonly_nonvalued_nohint,
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_boolean_trap/FBT.py:81:19: FBT001 Boolean positional arg in function definition
|
||||
|
|
||||
81 | # FBT001: Boolean positional arg in function definition
|
||||
82 | def foo(self, value: bool) -> None:
|
||||
| ^^^^^^^^^^^ FBT001
|
||||
83 | pass
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,61 +1,44 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_boolean_trap/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: BooleanDefaultValueInFunctionDefinition
|
||||
body: Boolean default value in function definition
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 12
|
||||
column: 30
|
||||
end_location:
|
||||
row: 12
|
||||
column: 34
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BooleanDefaultValueInFunctionDefinition
|
||||
body: Boolean default value in function definition
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 42
|
||||
end_location:
|
||||
row: 13
|
||||
column: 46
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BooleanDefaultValueInFunctionDefinition
|
||||
body: Boolean default value in function definition
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 14
|
||||
column: 40
|
||||
end_location:
|
||||
row: 14
|
||||
column: 44
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BooleanDefaultValueInFunctionDefinition
|
||||
body: Boolean default value in function definition
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 15
|
||||
column: 45
|
||||
end_location:
|
||||
row: 15
|
||||
column: 49
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_boolean_trap/FBT.py:12:31: FBT002 Boolean default value in function definition
|
||||
|
|
||||
12 | posorkw_nonvalued_boolhint: bool,
|
||||
13 | posorkw_nonvalued_boolstrhint: "bool",
|
||||
14 | posorkw_boolvalued_nohint=True,
|
||||
| ^^^^ FBT002
|
||||
15 | posorkw_boolvalued_nonboolhint: int = True,
|
||||
16 | posorkw_boolvalued_boolhint: bool = True,
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_boolean_trap/FBT.py:13:43: FBT002 Boolean default value in function definition
|
||||
|
|
||||
13 | posorkw_nonvalued_boolstrhint: "bool",
|
||||
14 | posorkw_boolvalued_nohint=True,
|
||||
15 | posorkw_boolvalued_nonboolhint: int = True,
|
||||
| ^^^^ FBT002
|
||||
16 | posorkw_boolvalued_boolhint: bool = True,
|
||||
17 | posorkw_boolvalued_boolstrhint: "bool" = True,
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_boolean_trap/FBT.py:14:41: FBT002 Boolean default value in function definition
|
||||
|
|
||||
14 | posorkw_boolvalued_nohint=True,
|
||||
15 | posorkw_boolvalued_nonboolhint: int = True,
|
||||
16 | posorkw_boolvalued_boolhint: bool = True,
|
||||
| ^^^^ FBT002
|
||||
17 | posorkw_boolvalued_boolstrhint: "bool" = True,
|
||||
18 | posorkw_nonboolvalued_nohint=1,
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_boolean_trap/FBT.py:15:46: FBT002 Boolean default value in function definition
|
||||
|
|
||||
15 | posorkw_boolvalued_nonboolhint: int = True,
|
||||
16 | posorkw_boolvalued_boolhint: bool = True,
|
||||
17 | posorkw_boolvalued_boolstrhint: "bool" = True,
|
||||
| ^^^^ FBT002
|
||||
18 | posorkw_nonboolvalued_nohint=1,
|
||||
19 | posorkw_nonboolvalued_nonboolhint: int = 2,
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,47 +1,31 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_boolean_trap/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: BooleanPositionalValueInFunctionCall
|
||||
body: Boolean positional value in function call
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 42
|
||||
column: 10
|
||||
end_location:
|
||||
row: 42
|
||||
column: 14
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BooleanPositionalValueInFunctionCall
|
||||
body: Boolean positional value in function call
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 57
|
||||
column: 10
|
||||
end_location:
|
||||
row: 57
|
||||
column: 14
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BooleanPositionalValueInFunctionCall
|
||||
body: Boolean positional value in function call
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 57
|
||||
column: 16
|
||||
end_location:
|
||||
row: 57
|
||||
column: 21
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_boolean_trap/FBT.py:42:11: FBT003 Boolean positional value in function call
|
||||
|
|
||||
42 | used("a", True)
|
||||
| ^^^^ FBT003
|
||||
43 | used(do=True)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_boolean_trap/FBT.py:57:11: FBT003 Boolean positional value in function call
|
||||
|
|
||||
57 | {}.pop(True, False)
|
||||
58 | dict.fromkeys(("world",), True)
|
||||
59 | {}.deploy(True, False)
|
||||
| ^^^^ FBT003
|
||||
60 | getattr(someobj, attrname, False)
|
||||
61 | mylist.index(True)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_boolean_trap/FBT.py:57:17: FBT003 Boolean positional value in function call
|
||||
|
|
||||
57 | {}.pop(True, False)
|
||||
58 | dict.fromkeys(("world",), True)
|
||||
59 | {}.deploy(True, False)
|
||||
| ^^^^^ FBT003
|
||||
60 | getattr(someobj, attrname, False)
|
||||
61 | mylist.index(True)
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -6,8 +6,9 @@ pub mod settings;
|
|||
mod tests {
|
||||
use std::path::Path;
|
||||
|
||||
use crate::assert_messages;
|
||||
use anyhow::Result;
|
||||
use insta::assert_yaml_snapshot;
|
||||
|
||||
use test_case::test_case;
|
||||
|
||||
use crate::registry::Rule;
|
||||
|
@ -54,7 +55,7 @@ mod tests {
|
|||
Path::new("flake8_bugbear").join(path).as_path(),
|
||||
&Settings::for_rule(rule_code),
|
||||
)?;
|
||||
assert_yaml_snapshot!(snapshot, diagnostics);
|
||||
assert_messages!(snapshot, diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -73,7 +74,7 @@ mod tests {
|
|||
..Settings::for_rules(vec![Rule::FunctionCallInDefaultArgument])
|
||||
},
|
||||
)?;
|
||||
assert_yaml_snapshot!(snapshot, diagnostics);
|
||||
assert_messages!(snapshot, diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: UnaryPrefixIncrement
|
||||
body: Python does not support the unary prefix increment
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 15
|
||||
column: 8
|
||||
end_location:
|
||||
row: 15
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnaryPrefixIncrement
|
||||
body: Python does not support the unary prefix increment
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 20
|
||||
column: 11
|
||||
end_location:
|
||||
row: 20
|
||||
column: 14
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B002.py:15:9: B002 Python does not support the unary prefix increment
|
||||
|
|
||||
15 | def this_is_buggy(n):
|
||||
16 | x = ++n
|
||||
| ^^^ B002
|
||||
17 | return x
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B002.py:20:12: B002 Python does not support the unary prefix increment
|
||||
|
|
||||
20 | def this_is_buggy_too(n):
|
||||
21 | return ++n
|
||||
| ^^^ B002
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,19 +1,13 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: AssignmentToOsEnviron
|
||||
body: "Assigning to `os.environ` doesn't clear the environment"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 9
|
||||
column: 0
|
||||
end_location:
|
||||
row: 9
|
||||
column: 10
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B003.py:9:1: B003 Assigning to `os.environ` doesn't clear the environment
|
||||
|
|
||||
9 | from os import environ
|
||||
10 |
|
||||
11 | os.environ = {}
|
||||
| ^^^^^^^^^^ B003
|
||||
12 | environ = {} # that's fine, assigning a new meaning to the module-level name
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,33 +1,23 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: UnreliableCallableCheck
|
||||
body: "Using `hasattr(x, '__call__')` to test if x is callable is unreliable. Use `callable(x)` for consistent results."
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 3
|
||||
column: 7
|
||||
end_location:
|
||||
row: 3
|
||||
column: 29
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnreliableCallableCheck
|
||||
body: "Using `hasattr(x, '__call__')` to test if x is callable is unreliable. Use `callable(x)` for consistent results."
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 7
|
||||
end_location:
|
||||
row: 5
|
||||
column: 36
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B004.py:3:8: B004 Using `hasattr(x, '__call__')` to test if x is callable is unreliable. Use `callable(x)` for consistent results.
|
||||
|
|
||||
3 | def this_is_a_bug():
|
||||
4 | o = object()
|
||||
5 | if hasattr(o, "__call__"):
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ B004
|
||||
6 | print("Ooh, callable! Or is it?")
|
||||
7 | if getattr(o, "__call__", False):
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B004.py:5:8: B004 Using `hasattr(x, '__call__')` to test if x is callable is unreliable. Use `callable(x)` for consistent results.
|
||||
|
|
||||
5 | if hasattr(o, "__call__"):
|
||||
6 | print("Ooh, callable! Or is it?")
|
||||
7 | if getattr(o, "__call__", False):
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B004
|
||||
8 | print("Ooh, callable! Or is it?")
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,117 +1,84 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: StripWithMultiCharacters
|
||||
body: "Using `.strip()` with multi-character strings is misleading the reader"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 0
|
||||
end_location:
|
||||
row: 4
|
||||
column: 24
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: StripWithMultiCharacters
|
||||
body: "Using `.strip()` with multi-character strings is misleading the reader"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 7
|
||||
column: 0
|
||||
end_location:
|
||||
row: 7
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: StripWithMultiCharacters
|
||||
body: "Using `.strip()` with multi-character strings is misleading the reader"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 10
|
||||
column: 0
|
||||
end_location:
|
||||
row: 10
|
||||
column: 25
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: StripWithMultiCharacters
|
||||
body: "Using `.strip()` with multi-character strings is misleading the reader"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 0
|
||||
end_location:
|
||||
row: 13
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: StripWithMultiCharacters
|
||||
body: "Using `.strip()` with multi-character strings is misleading the reader"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 16
|
||||
column: 0
|
||||
end_location:
|
||||
row: 16
|
||||
column: 25
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: StripWithMultiCharacters
|
||||
body: "Using `.strip()` with multi-character strings is misleading the reader"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 19
|
||||
column: 0
|
||||
end_location:
|
||||
row: 19
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: StripWithMultiCharacters
|
||||
body: "Using `.strip()` with multi-character strings is misleading the reader"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 22
|
||||
column: 0
|
||||
end_location:
|
||||
row: 22
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: StripWithMultiCharacters
|
||||
body: "Using `.strip()` with multi-character strings is misleading the reader"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 24
|
||||
column: 0
|
||||
end_location:
|
||||
row: 24
|
||||
column: 35
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B005.py:4:1: B005 Using `.strip()` with multi-character strings is misleading the reader
|
||||
|
|
||||
4 | s.strip(s) # no warning
|
||||
5 | s.strip("we") # no warning
|
||||
6 | s.strip(".facebook.com") # warning
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ B005
|
||||
7 | s.strip("e") # no warning
|
||||
8 | s.strip("\n\t ") # no warning
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B005.py:7:1: B005 Using `.strip()` with multi-character strings is misleading the reader
|
||||
|
|
||||
7 | s.strip("e") # no warning
|
||||
8 | s.strip("\n\t ") # no warning
|
||||
9 | s.strip(r"\n\t ") # warning
|
||||
| ^^^^^^^^^^^^^^^^^ B005
|
||||
10 | s.lstrip(s) # no warning
|
||||
11 | s.lstrip("we") # no warning
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B005.py:10:1: B005 Using `.strip()` with multi-character strings is misleading the reader
|
||||
|
|
||||
10 | s.lstrip(s) # no warning
|
||||
11 | s.lstrip("we") # no warning
|
||||
12 | s.lstrip(".facebook.com") # warning
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ B005
|
||||
13 | s.lstrip("e") # no warning
|
||||
14 | s.lstrip("\n\t ") # no warning
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B005.py:13:1: B005 Using `.strip()` with multi-character strings is misleading the reader
|
||||
|
|
||||
13 | s.lstrip("e") # no warning
|
||||
14 | s.lstrip("\n\t ") # no warning
|
||||
15 | s.lstrip(r"\n\t ") # warning
|
||||
| ^^^^^^^^^^^^^^^^^^ B005
|
||||
16 | s.rstrip(s) # no warning
|
||||
17 | s.rstrip("we") # warning
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B005.py:16:1: B005 Using `.strip()` with multi-character strings is misleading the reader
|
||||
|
|
||||
16 | s.rstrip(s) # no warning
|
||||
17 | s.rstrip("we") # warning
|
||||
18 | s.rstrip(".facebook.com") # warning
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ B005
|
||||
19 | s.rstrip("e") # no warning
|
||||
20 | s.rstrip("\n\t ") # no warning
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B005.py:19:1: B005 Using `.strip()` with multi-character strings is misleading the reader
|
||||
|
|
||||
19 | s.rstrip("e") # no warning
|
||||
20 | s.rstrip("\n\t ") # no warning
|
||||
21 | s.rstrip(r"\n\t ") # warning
|
||||
| ^^^^^^^^^^^^^^^^^^ B005
|
||||
22 | s.strip("a") # no warning
|
||||
23 | s.strip("あ") # no warning
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B005.py:22:1: B005 Using `.strip()` with multi-character strings is misleading the reader
|
||||
|
|
||||
22 | s.strip("a") # no warning
|
||||
23 | s.strip("あ") # no warning
|
||||
24 | s.strip("ああ") # warning
|
||||
| ^^^^^^^^^^^^^^^ B005
|
||||
25 | s.strip("\ufeff") # no warning
|
||||
26 | s.strip("\u0074\u0065\u0073\u0074") # warning
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B005.py:24:1: B005 Using `.strip()` with multi-character strings is misleading the reader
|
||||
|
|
||||
24 | s.strip("ああ") # warning
|
||||
25 | s.strip("\ufeff") # no warning
|
||||
26 | s.strip("\u0074\u0065\u0073\u0074") # warning
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B005
|
||||
27 |
|
||||
28 | from somewhere import other_type, strip
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,201 +1,113 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: MutableArgumentDefault
|
||||
body: Do not use mutable data structures for argument defaults
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 62
|
||||
column: 24
|
||||
end_location:
|
||||
row: 62
|
||||
column: 33
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MutableArgumentDefault
|
||||
body: Do not use mutable data structures for argument defaults
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 66
|
||||
column: 29
|
||||
end_location:
|
||||
row: 66
|
||||
column: 31
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MutableArgumentDefault
|
||||
body: Do not use mutable data structures for argument defaults
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 70
|
||||
column: 19
|
||||
end_location:
|
||||
row: 70
|
||||
column: 24
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MutableArgumentDefault
|
||||
body: Do not use mutable data structures for argument defaults
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 74
|
||||
column: 19
|
||||
end_location:
|
||||
row: 74
|
||||
column: 44
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MutableArgumentDefault
|
||||
body: Do not use mutable data structures for argument defaults
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 78
|
||||
column: 31
|
||||
end_location:
|
||||
row: 78
|
||||
column: 56
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MutableArgumentDefault
|
||||
body: Do not use mutable data structures for argument defaults
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 82
|
||||
column: 25
|
||||
end_location:
|
||||
row: 82
|
||||
column: 44
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MutableArgumentDefault
|
||||
body: Do not use mutable data structures for argument defaults
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 87
|
||||
column: 45
|
||||
end_location:
|
||||
row: 87
|
||||
column: 69
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MutableArgumentDefault
|
||||
body: Do not use mutable data structures for argument defaults
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 91
|
||||
column: 45
|
||||
end_location:
|
||||
row: 91
|
||||
column: 72
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MutableArgumentDefault
|
||||
body: Do not use mutable data structures for argument defaults
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 95
|
||||
column: 44
|
||||
end_location:
|
||||
row: 95
|
||||
column: 68
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MutableArgumentDefault
|
||||
body: Do not use mutable data structures for argument defaults
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 99
|
||||
column: 32
|
||||
end_location:
|
||||
row: 99
|
||||
column: 34
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MutableArgumentDefault
|
||||
body: Do not use mutable data structures for argument defaults
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 192
|
||||
column: 19
|
||||
end_location:
|
||||
row: 192
|
||||
column: 48
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MutableArgumentDefault
|
||||
body: Do not use mutable data structures for argument defaults
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 225
|
||||
column: 26
|
||||
end_location:
|
||||
row: 225
|
||||
column: 28
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MutableArgumentDefault
|
||||
body: Do not use mutable data structures for argument defaults
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 226
|
||||
column: 34
|
||||
end_location:
|
||||
row: 226
|
||||
column: 36
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: MutableArgumentDefault
|
||||
body: Do not use mutable data structures for argument defaults
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 227
|
||||
column: 61
|
||||
end_location:
|
||||
row: 227
|
||||
column: 66
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:62:25: B006 Do not use mutable data structures for argument defaults
|
||||
|
|
||||
62 | def this_is_wrong(value=[1, 2, 3]):
|
||||
| ^^^^^^^^^ B006
|
||||
63 | ...
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:66:30: B006 Do not use mutable data structures for argument defaults
|
||||
|
|
||||
66 | def this_is_also_wrong(value={}):
|
||||
| ^^ B006
|
||||
67 | ...
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:70:20: B006 Do not use mutable data structures for argument defaults
|
||||
|
|
||||
70 | def and_this(value=set()):
|
||||
| ^^^^^ B006
|
||||
71 | ...
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:74:20: B006 Do not use mutable data structures for argument defaults
|
||||
|
|
||||
74 | def this_too(value=collections.OrderedDict()):
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ B006
|
||||
75 | ...
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:78:32: B006 Do not use mutable data structures for argument defaults
|
||||
|
|
||||
78 | async def async_this_too(value=collections.defaultdict()):
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ B006
|
||||
79 | ...
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:82:26: B006 Do not use mutable data structures for argument defaults
|
||||
|
|
||||
82 | def dont_forget_me(value=collections.deque()):
|
||||
| ^^^^^^^^^^^^^^^^^^^ B006
|
||||
83 | ...
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:87:46: B006 Do not use mutable data structures for argument defaults
|
||||
|
|
||||
87 | # N.B. we're also flagging the function call in the comprehension
|
||||
88 | def list_comprehension_also_not_okay(default=[i**2 for i in range(3)]):
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ B006
|
||||
89 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:91:46: B006 Do not use mutable data structures for argument defaults
|
||||
|
|
||||
91 | def dict_comprehension_also_not_okay(default={i: i**2 for i in range(3)}):
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B006
|
||||
92 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:95:45: B006 Do not use mutable data structures for argument defaults
|
||||
|
|
||||
95 | def set_comprehension_also_not_okay(default={i**2 for i in range(3)}):
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ B006
|
||||
96 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:99:33: B006 Do not use mutable data structures for argument defaults
|
||||
|
|
||||
99 | def kwonlyargs_mutable(*, value=[]):
|
||||
| ^^ B006
|
||||
100 | ...
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:192:20: B006 Do not use mutable data structures for argument defaults
|
||||
|
|
||||
192 | # B006 and B008
|
||||
193 | # We should handle arbitrary nesting of these B008.
|
||||
194 | def nested_combo(a=[float(3), dt.datetime.now()]):
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B006
|
||||
195 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:225:27: B006 Do not use mutable data structures for argument defaults
|
||||
|
|
||||
225 | def mutable_annotations(
|
||||
226 | a: list[int] | None = [],
|
||||
| ^^ B006
|
||||
227 | b: Optional[Dict[int, int]] = {},
|
||||
228 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(),
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:226:35: B006 Do not use mutable data structures for argument defaults
|
||||
|
|
||||
226 | def mutable_annotations(
|
||||
227 | a: list[int] | None = [],
|
||||
228 | b: Optional[Dict[int, int]] = {},
|
||||
| ^^ B006
|
||||
229 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(),
|
||||
230 | ):
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:227:62: B006 Do not use mutable data structures for argument defaults
|
||||
|
|
||||
227 | a: list[int] | None = [],
|
||||
228 | b: Optional[Dict[int, int]] = {},
|
||||
229 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(),
|
||||
| ^^^^^ B006
|
||||
230 | ):
|
||||
231 | pass
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,222 +1,181 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: UnusedLoopControlVariable
|
||||
body: "Loop control variable `i` not used within loop body"
|
||||
suggestion: "Rename unused `i` to `_i`"
|
||||
fixable: true
|
||||
location:
|
||||
row: 6
|
||||
column: 4
|
||||
end_location:
|
||||
row: 6
|
||||
column: 5
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnusedLoopControlVariable
|
||||
body: "Loop control variable `k` not used within loop body"
|
||||
suggestion: "Rename unused `k` to `_k`"
|
||||
fixable: true
|
||||
location:
|
||||
row: 18
|
||||
column: 12
|
||||
end_location:
|
||||
row: 18
|
||||
column: 13
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 18
|
||||
column: 12
|
||||
end_location:
|
||||
row: 18
|
||||
column: 13
|
||||
content: _k
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnusedLoopControlVariable
|
||||
body: "Loop control variable `i` not used within loop body"
|
||||
suggestion: "Rename unused `i` to `_i`"
|
||||
fixable: true
|
||||
location:
|
||||
row: 30
|
||||
column: 4
|
||||
end_location:
|
||||
row: 30
|
||||
column: 5
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnusedLoopControlVariable
|
||||
body: "Loop control variable `k` not used within loop body"
|
||||
suggestion: "Rename unused `k` to `_k`"
|
||||
fixable: true
|
||||
location:
|
||||
row: 30
|
||||
column: 12
|
||||
end_location:
|
||||
row: 30
|
||||
column: 13
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 30
|
||||
column: 12
|
||||
end_location:
|
||||
row: 30
|
||||
column: 13
|
||||
content: _k
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnusedLoopControlVariable
|
||||
body: "Loop control variable `bar` may not be used within loop body"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 34
|
||||
column: 9
|
||||
end_location:
|
||||
row: 34
|
||||
column: 12
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnusedLoopControlVariable
|
||||
body: "Loop control variable `bar` may not be used within loop body"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 38
|
||||
column: 9
|
||||
end_location:
|
||||
row: 38
|
||||
column: 12
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnusedLoopControlVariable
|
||||
body: "Loop control variable `bar` may not be used within loop body"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 42
|
||||
column: 9
|
||||
end_location:
|
||||
row: 42
|
||||
column: 12
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnusedLoopControlVariable
|
||||
body: "Loop control variable `bar` may not be used within loop body"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 46
|
||||
column: 9
|
||||
end_location:
|
||||
row: 46
|
||||
column: 12
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnusedLoopControlVariable
|
||||
body: "Loop control variable `bar` not used within loop body"
|
||||
suggestion: "Rename unused `bar` to `_bar`"
|
||||
fixable: true
|
||||
location:
|
||||
row: 52
|
||||
column: 13
|
||||
end_location:
|
||||
row: 52
|
||||
column: 16
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 52
|
||||
column: 13
|
||||
end_location:
|
||||
row: 52
|
||||
column: 16
|
||||
content: _bar
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnusedLoopControlVariable
|
||||
body: "Loop control variable `bar` not used within loop body"
|
||||
suggestion: "Rename unused `bar` to `_bar`"
|
||||
fixable: true
|
||||
location:
|
||||
row: 59
|
||||
column: 13
|
||||
end_location:
|
||||
row: 59
|
||||
column: 16
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnusedLoopControlVariable
|
||||
body: "Loop control variable `bar` not used within loop body"
|
||||
suggestion: "Rename unused `bar` to `_bar`"
|
||||
fixable: true
|
||||
location:
|
||||
row: 68
|
||||
column: 13
|
||||
end_location:
|
||||
row: 68
|
||||
column: 16
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 68
|
||||
column: 13
|
||||
end_location:
|
||||
row: 68
|
||||
column: 16
|
||||
content: _bar
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnusedLoopControlVariable
|
||||
body: "Loop control variable `bar` not used within loop body"
|
||||
suggestion: "Rename unused `bar` to `_bar`"
|
||||
fixable: true
|
||||
location:
|
||||
row: 77
|
||||
column: 13
|
||||
end_location:
|
||||
row: 77
|
||||
column: 16
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 77
|
||||
column: 13
|
||||
end_location:
|
||||
row: 77
|
||||
column: 16
|
||||
content: _bar
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnusedLoopControlVariable
|
||||
body: "Loop control variable `line_` not used within loop body"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 87
|
||||
column: 4
|
||||
end_location:
|
||||
row: 87
|
||||
column: 9
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B007.py:6:5: B007 [*] Loop control variable `i` not used within loop body
|
||||
|
|
||||
6 | print(i) # name no longer defined on Python 3; no warning yet
|
||||
7 |
|
||||
8 | for i in range(10): # name not used within the loop; B007
|
||||
| ^ B007
|
||||
9 | print(10)
|
||||
|
|
||||
= help: Rename unused `i` to `_i`
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B007.py:18:13: B007 [*] Loop control variable `k` not used within loop body
|
||||
|
|
||||
18 | for i in range(10):
|
||||
19 | for j in range(10):
|
||||
20 | for k in range(10): # k not used, i and j used transitively
|
||||
| ^ B007
|
||||
21 | print(i + j)
|
||||
|
|
||||
= help: Rename unused `k` to `_k`
|
||||
|
||||
ℹ Suggested fix
|
||||
15 15 |
|
||||
16 16 | for i in range(10):
|
||||
17 17 | for j in range(10):
|
||||
18 |- for k in range(10): # k not used, i and j used transitively
|
||||
18 |+ for _k in range(10): # k not used, i and j used transitively
|
||||
19 19 | print(i + j)
|
||||
20 20 |
|
||||
21 21 |
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B007.py:30:5: B007 [*] Loop control variable `i` not used within loop body
|
||||
|
|
||||
30 | for i, (j, (k, l)) in strange_generator(): # i, k not used
|
||||
| ^ B007
|
||||
31 | print(j, l)
|
||||
|
|
||||
= help: Rename unused `i` to `_i`
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B007.py:30:13: B007 [*] Loop control variable `k` not used within loop body
|
||||
|
|
||||
30 | for i, (j, (k, l)) in strange_generator(): # i, k not used
|
||||
| ^ B007
|
||||
31 | print(j, l)
|
||||
|
|
||||
= help: Rename unused `k` to `_k`
|
||||
|
||||
ℹ Suggested fix
|
||||
27 27 | yield i, (j, (k, l))
|
||||
28 28 |
|
||||
29 29 |
|
||||
30 |-for i, (j, (k, l)) in strange_generator(): # i, k not used
|
||||
30 |+for i, (j, (_k, l)) in strange_generator(): # i, k not used
|
||||
31 31 | print(j, l)
|
||||
32 32 |
|
||||
33 33 | FMT = "{foo} {bar}"
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B007.py:34:10: B007 Loop control variable `bar` may not be used within loop body
|
||||
|
|
||||
34 | FMT = "{foo} {bar}"
|
||||
35 | for foo, bar in [(1, 2)]:
|
||||
| ^^^ B007
|
||||
36 | if foo:
|
||||
37 | print(FMT.format(**locals()))
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B007.py:38:10: B007 Loop control variable `bar` may not be used within loop body
|
||||
|
|
||||
38 | print(FMT.format(**locals()))
|
||||
39 |
|
||||
40 | for foo, bar in [(1, 2)]:
|
||||
| ^^^ B007
|
||||
41 | if foo:
|
||||
42 | print(FMT.format(**globals()))
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B007.py:42:10: B007 Loop control variable `bar` may not be used within loop body
|
||||
|
|
||||
42 | print(FMT.format(**globals()))
|
||||
43 |
|
||||
44 | for foo, bar in [(1, 2)]:
|
||||
| ^^^ B007
|
||||
45 | if foo:
|
||||
46 | print(FMT.format(**vars()))
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B007.py:46:10: B007 Loop control variable `bar` may not be used within loop body
|
||||
|
|
||||
46 | print(FMT.format(**vars()))
|
||||
47 |
|
||||
48 | for foo, bar in [(1, 2)]:
|
||||
| ^^^ B007
|
||||
49 | print(FMT.format(foo=foo, bar=eval("bar")))
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B007.py:52:14: B007 [*] Loop control variable `bar` not used within loop body
|
||||
|
|
||||
52 | def f():
|
||||
53 | # Fixable.
|
||||
54 | for foo, bar, baz in (["1", "2", "3"],):
|
||||
| ^^^ B007
|
||||
55 | if foo or baz:
|
||||
56 | break
|
||||
|
|
||||
= help: Rename unused `bar` to `_bar`
|
||||
|
||||
ℹ Suggested fix
|
||||
49 49 |
|
||||
50 50 | def f():
|
||||
51 51 | # Fixable.
|
||||
52 |- for foo, bar, baz in (["1", "2", "3"],):
|
||||
52 |+ for foo, _bar, baz in (["1", "2", "3"],):
|
||||
53 53 | if foo or baz:
|
||||
54 54 | break
|
||||
55 55 |
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B007.py:59:14: B007 [*] Loop control variable `bar` not used within loop body
|
||||
|
|
||||
59 | def f():
|
||||
60 | # Unfixable due to usage of `bar` outside of loop.
|
||||
61 | for foo, bar, baz in (["1", "2", "3"],):
|
||||
| ^^^ B007
|
||||
62 | if foo or baz:
|
||||
63 | break
|
||||
|
|
||||
= help: Rename unused `bar` to `_bar`
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B007.py:68:14: B007 [*] Loop control variable `bar` not used within loop body
|
||||
|
|
||||
68 | def f():
|
||||
69 | # Fixable.
|
||||
70 | for foo, bar, baz in (["1", "2", "3"],):
|
||||
| ^^^ B007
|
||||
71 | if foo or baz:
|
||||
72 | break
|
||||
|
|
||||
= help: Rename unused `bar` to `_bar`
|
||||
|
||||
ℹ Suggested fix
|
||||
65 65 |
|
||||
66 66 | def f():
|
||||
67 67 | # Fixable.
|
||||
68 |- for foo, bar, baz in (["1", "2", "3"],):
|
||||
68 |+ for foo, _bar, baz in (["1", "2", "3"],):
|
||||
69 69 | if foo or baz:
|
||||
70 70 | break
|
||||
71 71 |
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B007.py:77:14: B007 [*] Loop control variable `bar` not used within loop body
|
||||
|
|
||||
77 | def f():
|
||||
78 | # Fixable.
|
||||
79 | for foo, bar, baz in (["1", "2", "3"],):
|
||||
| ^^^ B007
|
||||
80 | if foo or baz:
|
||||
81 | break
|
||||
|
|
||||
= help: Rename unused `bar` to `_bar`
|
||||
|
||||
ℹ Suggested fix
|
||||
74 74 |
|
||||
75 75 | def f():
|
||||
76 76 | # Fixable.
|
||||
77 |- for foo, bar, baz in (["1", "2", "3"],):
|
||||
77 |+ for foo, _bar, baz in (["1", "2", "3"],):
|
||||
78 78 | if foo or baz:
|
||||
79 79 | break
|
||||
80 80 |
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B007.py:87:5: B007 Loop control variable `line_` not used within loop body
|
||||
|
|
||||
87 | # Unfixable due to trailing underscore (`_line_` wouldn't be considered an ignorable
|
||||
88 | # variable name).
|
||||
89 | for line_ in range(self.header_lines):
|
||||
| ^^^^^ B007
|
||||
90 | fp.readline()
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,201 +1,114 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: FunctionCallInDefaultArgument
|
||||
body: "Do not perform function call `range` in argument defaults"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 87
|
||||
column: 60
|
||||
end_location:
|
||||
row: 87
|
||||
column: 68
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionCallInDefaultArgument
|
||||
body: "Do not perform function call `range` in argument defaults"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 91
|
||||
column: 63
|
||||
end_location:
|
||||
row: 91
|
||||
column: 71
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionCallInDefaultArgument
|
||||
body: "Do not perform function call `range` in argument defaults"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 95
|
||||
column: 59
|
||||
end_location:
|
||||
row: 95
|
||||
column: 67
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionCallInDefaultArgument
|
||||
body: "Do not perform function call `time.time` in argument defaults"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 111
|
||||
column: 38
|
||||
end_location:
|
||||
row: 111
|
||||
column: 49
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionCallInDefaultArgument
|
||||
body: "Do not perform function call `dt.datetime.now` in argument defaults"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 115
|
||||
column: 11
|
||||
end_location:
|
||||
row: 115
|
||||
column: 28
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionCallInDefaultArgument
|
||||
body: Do not perform function call in argument defaults
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 119
|
||||
column: 29
|
||||
end_location:
|
||||
row: 119
|
||||
column: 44
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionCallInDefaultArgument
|
||||
body: "Do not perform function call `float` in argument defaults"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 157
|
||||
column: 33
|
||||
end_location:
|
||||
row: 157
|
||||
column: 47
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionCallInDefaultArgument
|
||||
body: "Do not perform function call `float` in argument defaults"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 162
|
||||
column: 29
|
||||
end_location:
|
||||
row: 162
|
||||
column: 37
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionCallInDefaultArgument
|
||||
body: "Do not perform function call `float` in argument defaults"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 166
|
||||
column: 44
|
||||
end_location:
|
||||
row: 166
|
||||
column: 57
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionCallInDefaultArgument
|
||||
body: "Do not perform function call `float` in argument defaults"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 192
|
||||
column: 20
|
||||
end_location:
|
||||
row: 192
|
||||
column: 28
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionCallInDefaultArgument
|
||||
body: "Do not perform function call `dt.datetime.now` in argument defaults"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 192
|
||||
column: 30
|
||||
end_location:
|
||||
row: 192
|
||||
column: 47
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionCallInDefaultArgument
|
||||
body: "Do not perform function call `map` in argument defaults"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 198
|
||||
column: 21
|
||||
end_location:
|
||||
row: 198
|
||||
column: 62
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionCallInDefaultArgument
|
||||
body: "Do not perform function call `random.randint` in argument defaults"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 203
|
||||
column: 18
|
||||
end_location:
|
||||
row: 203
|
||||
column: 59
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionCallInDefaultArgument
|
||||
body: "Do not perform function call `dt.datetime.now` in argument defaults"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 203
|
||||
column: 36
|
||||
end_location:
|
||||
row: 203
|
||||
column: 53
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:87:61: B008 Do not perform function call `range` in argument defaults
|
||||
|
|
||||
87 | # N.B. we're also flagging the function call in the comprehension
|
||||
88 | def list_comprehension_also_not_okay(default=[i**2 for i in range(3)]):
|
||||
| ^^^^^^^^ B008
|
||||
89 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:91:64: B008 Do not perform function call `range` in argument defaults
|
||||
|
|
||||
91 | def dict_comprehension_also_not_okay(default={i: i**2 for i in range(3)}):
|
||||
| ^^^^^^^^ B008
|
||||
92 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:95:60: B008 Do not perform function call `range` in argument defaults
|
||||
|
|
||||
95 | def set_comprehension_also_not_okay(default={i**2 for i in range(3)}):
|
||||
| ^^^^^^^^ B008
|
||||
96 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:111:39: B008 Do not perform function call `time.time` in argument defaults
|
||||
|
|
||||
111 | # B008
|
||||
112 | # Flag function calls as default args (including if they are part of a sub-expression)
|
||||
113 | def in_fact_all_calls_are_wrong(value=time.time()):
|
||||
| ^^^^^^^^^^^ B008
|
||||
114 | ...
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:115:12: B008 Do not perform function call `dt.datetime.now` in argument defaults
|
||||
|
|
||||
115 | def f(when=dt.datetime.now() + dt.timedelta(days=7)):
|
||||
| ^^^^^^^^^^^^^^^^^ B008
|
||||
116 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:119:30: B008 Do not perform function call in argument defaults
|
||||
|
|
||||
119 | def can_even_catch_lambdas(a=(lambda x: x)()):
|
||||
| ^^^^^^^^^^^^^^^ B008
|
||||
120 | ...
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:157:34: B008 Do not perform function call `float` in argument defaults
|
||||
|
|
||||
157 | def float_infinity_literal(value=float("1e999")):
|
||||
| ^^^^^^^^^^^^^^ B008
|
||||
158 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:162:30: B008 Do not perform function call `float` in argument defaults
|
||||
|
|
||||
162 | # But don't allow standard floats
|
||||
163 | def float_int_is_wrong(value=float(3)):
|
||||
| ^^^^^^^^ B008
|
||||
164 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:166:45: B008 Do not perform function call `float` in argument defaults
|
||||
|
|
||||
166 | def float_str_not_inf_or_nan_is_wrong(value=float("3.14")):
|
||||
| ^^^^^^^^^^^^^ B008
|
||||
167 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:192:21: B008 Do not perform function call `float` in argument defaults
|
||||
|
|
||||
192 | # B006 and B008
|
||||
193 | # We should handle arbitrary nesting of these B008.
|
||||
194 | def nested_combo(a=[float(3), dt.datetime.now()]):
|
||||
| ^^^^^^^^ B008
|
||||
195 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:192:31: B008 Do not perform function call `dt.datetime.now` in argument defaults
|
||||
|
|
||||
192 | # B006 and B008
|
||||
193 | # We should handle arbitrary nesting of these B008.
|
||||
194 | def nested_combo(a=[float(3), dt.datetime.now()]):
|
||||
| ^^^^^^^^^^^^^^^^^ B008
|
||||
195 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:198:22: B008 Do not perform function call `map` in argument defaults
|
||||
|
|
||||
198 | # Don't flag nested B006 since we can't guarantee that
|
||||
199 | # it isn't made mutable by the outer operation.
|
||||
200 | def no_nested_b006(a=map(lambda s: s.upper(), ["a", "b", "c"])):
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B008
|
||||
201 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:203:19: B008 Do not perform function call `random.randint` in argument defaults
|
||||
|
|
||||
203 | # B008-ception.
|
||||
204 | def nested_b008(a=random.randint(0, dt.datetime.now().year)):
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B008
|
||||
205 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B006_B008.py:203:37: B008 Do not perform function call `dt.datetime.now` in argument defaults
|
||||
|
|
||||
203 | # B008-ception.
|
||||
204 | def nested_b008(a=random.randint(0, dt.datetime.now().year)):
|
||||
| ^^^^^^^^^^^^^^^^^ B008
|
||||
205 | pass
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,152 +1,149 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: GetAttrWithConstant
|
||||
body: "Do not call `getattr` with a constant attribute value. It is not any safer than normal property access."
|
||||
suggestion: "Replace `getattr` with attribute access"
|
||||
fixable: true
|
||||
location:
|
||||
row: 19
|
||||
column: 0
|
||||
end_location:
|
||||
row: 19
|
||||
column: 19
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 19
|
||||
column: 0
|
||||
end_location:
|
||||
row: 19
|
||||
column: 19
|
||||
content: foo.bar
|
||||
parent: ~
|
||||
- kind:
|
||||
name: GetAttrWithConstant
|
||||
body: "Do not call `getattr` with a constant attribute value. It is not any safer than normal property access."
|
||||
suggestion: "Replace `getattr` with attribute access"
|
||||
fixable: true
|
||||
location:
|
||||
row: 20
|
||||
column: 0
|
||||
end_location:
|
||||
row: 20
|
||||
column: 23
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 20
|
||||
column: 0
|
||||
end_location:
|
||||
row: 20
|
||||
column: 23
|
||||
content: foo._123abc
|
||||
parent: ~
|
||||
- kind:
|
||||
name: GetAttrWithConstant
|
||||
body: "Do not call `getattr` with a constant attribute value. It is not any safer than normal property access."
|
||||
suggestion: "Replace `getattr` with attribute access"
|
||||
fixable: true
|
||||
location:
|
||||
row: 21
|
||||
column: 0
|
||||
end_location:
|
||||
row: 21
|
||||
column: 26
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 21
|
||||
column: 0
|
||||
end_location:
|
||||
row: 21
|
||||
column: 26
|
||||
content: foo.__123abc__
|
||||
parent: ~
|
||||
- kind:
|
||||
name: GetAttrWithConstant
|
||||
body: "Do not call `getattr` with a constant attribute value. It is not any safer than normal property access."
|
||||
suggestion: "Replace `getattr` with attribute access"
|
||||
fixable: true
|
||||
location:
|
||||
row: 22
|
||||
column: 0
|
||||
end_location:
|
||||
row: 22
|
||||
column: 22
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 22
|
||||
column: 0
|
||||
end_location:
|
||||
row: 22
|
||||
column: 22
|
||||
content: foo.abc123
|
||||
parent: ~
|
||||
- kind:
|
||||
name: GetAttrWithConstant
|
||||
body: "Do not call `getattr` with a constant attribute value. It is not any safer than normal property access."
|
||||
suggestion: "Replace `getattr` with attribute access"
|
||||
fixable: true
|
||||
location:
|
||||
row: 23
|
||||
column: 0
|
||||
end_location:
|
||||
row: 23
|
||||
column: 23
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 23
|
||||
column: 0
|
||||
end_location:
|
||||
row: 23
|
||||
column: 23
|
||||
content: foo.abc123
|
||||
parent: ~
|
||||
- kind:
|
||||
name: GetAttrWithConstant
|
||||
body: "Do not call `getattr` with a constant attribute value. It is not any safer than normal property access."
|
||||
suggestion: "Replace `getattr` with attribute access"
|
||||
fixable: true
|
||||
location:
|
||||
row: 24
|
||||
column: 14
|
||||
end_location:
|
||||
row: 24
|
||||
column: 31
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 24
|
||||
column: 14
|
||||
end_location:
|
||||
row: 24
|
||||
column: 31
|
||||
content: x.bar
|
||||
parent: ~
|
||||
- kind:
|
||||
name: GetAttrWithConstant
|
||||
body: "Do not call `getattr` with a constant attribute value. It is not any safer than normal property access."
|
||||
suggestion: "Replace `getattr` with attribute access"
|
||||
fixable: true
|
||||
location:
|
||||
row: 25
|
||||
column: 3
|
||||
end_location:
|
||||
row: 25
|
||||
column: 20
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 25
|
||||
column: 3
|
||||
end_location:
|
||||
row: 25
|
||||
column: 20
|
||||
content: x.bar
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B009_B010.py:19:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access.
|
||||
|
|
||||
19 | # Invalid usage
|
||||
20 | getattr(foo, "bar")
|
||||
| ^^^^^^^^^^^^^^^^^^^ B009
|
||||
21 | getattr(foo, "_123abc")
|
||||
22 | getattr(foo, "__123abc__")
|
||||
|
|
||||
= help: Replace `getattr` with attribute access
|
||||
|
||||
ℹ Suggested fix
|
||||
16 16 | getattr(foo, "__123abc")
|
||||
17 17 |
|
||||
18 18 | # Invalid usage
|
||||
19 |-getattr(foo, "bar")
|
||||
19 |+foo.bar
|
||||
20 20 | getattr(foo, "_123abc")
|
||||
21 21 | getattr(foo, "__123abc__")
|
||||
22 22 | getattr(foo, "abc123")
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B009_B010.py:20:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access.
|
||||
|
|
||||
20 | # Invalid usage
|
||||
21 | getattr(foo, "bar")
|
||||
22 | getattr(foo, "_123abc")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ B009
|
||||
23 | getattr(foo, "__123abc__")
|
||||
24 | getattr(foo, "abc123")
|
||||
|
|
||||
= help: Replace `getattr` with attribute access
|
||||
|
||||
ℹ Suggested fix
|
||||
17 17 |
|
||||
18 18 | # Invalid usage
|
||||
19 19 | getattr(foo, "bar")
|
||||
20 |-getattr(foo, "_123abc")
|
||||
20 |+foo._123abc
|
||||
21 21 | getattr(foo, "__123abc__")
|
||||
22 22 | getattr(foo, "abc123")
|
||||
23 23 | getattr(foo, r"abc123")
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B009_B010.py:21:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access.
|
||||
|
|
||||
21 | getattr(foo, "bar")
|
||||
22 | getattr(foo, "_123abc")
|
||||
23 | getattr(foo, "__123abc__")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ B009
|
||||
24 | getattr(foo, "abc123")
|
||||
25 | getattr(foo, r"abc123")
|
||||
|
|
||||
= help: Replace `getattr` with attribute access
|
||||
|
||||
ℹ Suggested fix
|
||||
18 18 | # Invalid usage
|
||||
19 19 | getattr(foo, "bar")
|
||||
20 20 | getattr(foo, "_123abc")
|
||||
21 |-getattr(foo, "__123abc__")
|
||||
21 |+foo.__123abc__
|
||||
22 22 | getattr(foo, "abc123")
|
||||
23 23 | getattr(foo, r"abc123")
|
||||
24 24 | _ = lambda x: getattr(x, "bar")
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B009_B010.py:22:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access.
|
||||
|
|
||||
22 | getattr(foo, "_123abc")
|
||||
23 | getattr(foo, "__123abc__")
|
||||
24 | getattr(foo, "abc123")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ B009
|
||||
25 | getattr(foo, r"abc123")
|
||||
26 | _ = lambda x: getattr(x, "bar")
|
||||
|
|
||||
= help: Replace `getattr` with attribute access
|
||||
|
||||
ℹ Suggested fix
|
||||
19 19 | getattr(foo, "bar")
|
||||
20 20 | getattr(foo, "_123abc")
|
||||
21 21 | getattr(foo, "__123abc__")
|
||||
22 |-getattr(foo, "abc123")
|
||||
22 |+foo.abc123
|
||||
23 23 | getattr(foo, r"abc123")
|
||||
24 24 | _ = lambda x: getattr(x, "bar")
|
||||
25 25 | if getattr(x, "bar"):
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B009_B010.py:23:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access.
|
||||
|
|
||||
23 | getattr(foo, "__123abc__")
|
||||
24 | getattr(foo, "abc123")
|
||||
25 | getattr(foo, r"abc123")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ B009
|
||||
26 | _ = lambda x: getattr(x, "bar")
|
||||
27 | if getattr(x, "bar"):
|
||||
|
|
||||
= help: Replace `getattr` with attribute access
|
||||
|
||||
ℹ Suggested fix
|
||||
20 20 | getattr(foo, "_123abc")
|
||||
21 21 | getattr(foo, "__123abc__")
|
||||
22 22 | getattr(foo, "abc123")
|
||||
23 |-getattr(foo, r"abc123")
|
||||
23 |+foo.abc123
|
||||
24 24 | _ = lambda x: getattr(x, "bar")
|
||||
25 25 | if getattr(x, "bar"):
|
||||
26 26 | pass
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B009_B010.py:24:15: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access.
|
||||
|
|
||||
24 | getattr(foo, "abc123")
|
||||
25 | getattr(foo, r"abc123")
|
||||
26 | _ = lambda x: getattr(x, "bar")
|
||||
| ^^^^^^^^^^^^^^^^^ B009
|
||||
27 | if getattr(x, "bar"):
|
||||
28 | pass
|
||||
|
|
||||
= help: Replace `getattr` with attribute access
|
||||
|
||||
ℹ Suggested fix
|
||||
21 21 | getattr(foo, "__123abc__")
|
||||
22 22 | getattr(foo, "abc123")
|
||||
23 23 | getattr(foo, r"abc123")
|
||||
24 |-_ = lambda x: getattr(x, "bar")
|
||||
24 |+_ = lambda x: x.bar
|
||||
25 25 | if getattr(x, "bar"):
|
||||
26 26 | pass
|
||||
27 27 |
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B009_B010.py:25:4: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access.
|
||||
|
|
||||
25 | getattr(foo, r"abc123")
|
||||
26 | _ = lambda x: getattr(x, "bar")
|
||||
27 | if getattr(x, "bar"):
|
||||
| ^^^^^^^^^^^^^^^^^ B009
|
||||
28 | pass
|
||||
|
|
||||
= help: Replace `getattr` with attribute access
|
||||
|
||||
ℹ Suggested fix
|
||||
22 22 | getattr(foo, "abc123")
|
||||
23 23 | getattr(foo, r"abc123")
|
||||
24 24 | _ = lambda x: getattr(x, "bar")
|
||||
25 |-if getattr(x, "bar"):
|
||||
25 |+if x.bar:
|
||||
26 26 | pass
|
||||
27 27 |
|
||||
28 28 | # Valid setattr usage
|
||||
|
||||
|
||||
|
|
|
@ -1,131 +1,120 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: SetAttrWithConstant
|
||||
body: "Do not call `setattr` with a constant attribute value. It is not any safer than normal property access."
|
||||
suggestion: "Replace `setattr` with assignment"
|
||||
fixable: true
|
||||
location:
|
||||
row: 40
|
||||
column: 0
|
||||
end_location:
|
||||
row: 40
|
||||
column: 25
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 40
|
||||
column: 0
|
||||
end_location:
|
||||
row: 40
|
||||
column: 25
|
||||
content: foo.bar = None
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SetAttrWithConstant
|
||||
body: "Do not call `setattr` with a constant attribute value. It is not any safer than normal property access."
|
||||
suggestion: "Replace `setattr` with assignment"
|
||||
fixable: true
|
||||
location:
|
||||
row: 41
|
||||
column: 0
|
||||
end_location:
|
||||
row: 41
|
||||
column: 29
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 41
|
||||
column: 0
|
||||
end_location:
|
||||
row: 41
|
||||
column: 29
|
||||
content: foo._123abc = None
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SetAttrWithConstant
|
||||
body: "Do not call `setattr` with a constant attribute value. It is not any safer than normal property access."
|
||||
suggestion: "Replace `setattr` with assignment"
|
||||
fixable: true
|
||||
location:
|
||||
row: 42
|
||||
column: 0
|
||||
end_location:
|
||||
row: 42
|
||||
column: 32
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 42
|
||||
column: 0
|
||||
end_location:
|
||||
row: 42
|
||||
column: 32
|
||||
content: foo.__123abc__ = None
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SetAttrWithConstant
|
||||
body: "Do not call `setattr` with a constant attribute value. It is not any safer than normal property access."
|
||||
suggestion: "Replace `setattr` with assignment"
|
||||
fixable: true
|
||||
location:
|
||||
row: 43
|
||||
column: 0
|
||||
end_location:
|
||||
row: 43
|
||||
column: 28
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 43
|
||||
column: 0
|
||||
end_location:
|
||||
row: 43
|
||||
column: 28
|
||||
content: foo.abc123 = None
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SetAttrWithConstant
|
||||
body: "Do not call `setattr` with a constant attribute value. It is not any safer than normal property access."
|
||||
suggestion: "Replace `setattr` with assignment"
|
||||
fixable: true
|
||||
location:
|
||||
row: 44
|
||||
column: 0
|
||||
end_location:
|
||||
row: 44
|
||||
column: 29
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 44
|
||||
column: 0
|
||||
end_location:
|
||||
row: 44
|
||||
column: 29
|
||||
content: foo.abc123 = None
|
||||
parent: ~
|
||||
- kind:
|
||||
name: SetAttrWithConstant
|
||||
body: "Do not call `setattr` with a constant attribute value. It is not any safer than normal property access."
|
||||
suggestion: "Replace `setattr` with assignment"
|
||||
fixable: true
|
||||
location:
|
||||
row: 45
|
||||
column: 0
|
||||
end_location:
|
||||
row: 45
|
||||
column: 30
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 45
|
||||
column: 0
|
||||
end_location:
|
||||
row: 45
|
||||
column: 30
|
||||
content: foo.bar.baz = None
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B009_B010.py:40:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access.
|
||||
|
|
||||
40 | # Invalid usage
|
||||
41 | setattr(foo, "bar", None)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ B010
|
||||
42 | setattr(foo, "_123abc", None)
|
||||
43 | setattr(foo, "__123abc__", None)
|
||||
|
|
||||
= help: Replace `setattr` with assignment
|
||||
|
||||
ℹ Suggested fix
|
||||
37 37 | pass
|
||||
38 38 |
|
||||
39 39 | # Invalid usage
|
||||
40 |-setattr(foo, "bar", None)
|
||||
40 |+foo.bar = None
|
||||
41 41 | setattr(foo, "_123abc", None)
|
||||
42 42 | setattr(foo, "__123abc__", None)
|
||||
43 43 | setattr(foo, "abc123", None)
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B009_B010.py:41:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access.
|
||||
|
|
||||
41 | # Invalid usage
|
||||
42 | setattr(foo, "bar", None)
|
||||
43 | setattr(foo, "_123abc", None)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010
|
||||
44 | setattr(foo, "__123abc__", None)
|
||||
45 | setattr(foo, "abc123", None)
|
||||
|
|
||||
= help: Replace `setattr` with assignment
|
||||
|
||||
ℹ Suggested fix
|
||||
38 38 |
|
||||
39 39 | # Invalid usage
|
||||
40 40 | setattr(foo, "bar", None)
|
||||
41 |-setattr(foo, "_123abc", None)
|
||||
41 |+foo._123abc = None
|
||||
42 42 | setattr(foo, "__123abc__", None)
|
||||
43 43 | setattr(foo, "abc123", None)
|
||||
44 44 | setattr(foo, r"abc123", None)
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B009_B010.py:42:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access.
|
||||
|
|
||||
42 | setattr(foo, "bar", None)
|
||||
43 | setattr(foo, "_123abc", None)
|
||||
44 | setattr(foo, "__123abc__", None)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010
|
||||
45 | setattr(foo, "abc123", None)
|
||||
46 | setattr(foo, r"abc123", None)
|
||||
|
|
||||
= help: Replace `setattr` with assignment
|
||||
|
||||
ℹ Suggested fix
|
||||
39 39 | # Invalid usage
|
||||
40 40 | setattr(foo, "bar", None)
|
||||
41 41 | setattr(foo, "_123abc", None)
|
||||
42 |-setattr(foo, "__123abc__", None)
|
||||
42 |+foo.__123abc__ = None
|
||||
43 43 | setattr(foo, "abc123", None)
|
||||
44 44 | setattr(foo, r"abc123", None)
|
||||
45 45 | setattr(foo.bar, r"baz", None)
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B009_B010.py:43:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access.
|
||||
|
|
||||
43 | setattr(foo, "_123abc", None)
|
||||
44 | setattr(foo, "__123abc__", None)
|
||||
45 | setattr(foo, "abc123", None)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010
|
||||
46 | setattr(foo, r"abc123", None)
|
||||
47 | setattr(foo.bar, r"baz", None)
|
||||
|
|
||||
= help: Replace `setattr` with assignment
|
||||
|
||||
ℹ Suggested fix
|
||||
40 40 | setattr(foo, "bar", None)
|
||||
41 41 | setattr(foo, "_123abc", None)
|
||||
42 42 | setattr(foo, "__123abc__", None)
|
||||
43 |-setattr(foo, "abc123", None)
|
||||
43 |+foo.abc123 = None
|
||||
44 44 | setattr(foo, r"abc123", None)
|
||||
45 45 | setattr(foo.bar, r"baz", None)
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B009_B010.py:44:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access.
|
||||
|
|
||||
44 | setattr(foo, "__123abc__", None)
|
||||
45 | setattr(foo, "abc123", None)
|
||||
46 | setattr(foo, r"abc123", None)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010
|
||||
47 | setattr(foo.bar, r"baz", None)
|
||||
|
|
||||
= help: Replace `setattr` with assignment
|
||||
|
||||
ℹ Suggested fix
|
||||
41 41 | setattr(foo, "_123abc", None)
|
||||
42 42 | setattr(foo, "__123abc__", None)
|
||||
43 43 | setattr(foo, "abc123", None)
|
||||
44 |-setattr(foo, r"abc123", None)
|
||||
44 |+foo.abc123 = None
|
||||
45 45 | setattr(foo.bar, r"baz", None)
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B009_B010.py:45:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access.
|
||||
|
|
||||
45 | setattr(foo, "abc123", None)
|
||||
46 | setattr(foo, r"abc123", None)
|
||||
47 | setattr(foo.bar, r"baz", None)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010
|
||||
|
|
||||
= help: Replace `setattr` with assignment
|
||||
|
||||
ℹ Suggested fix
|
||||
42 42 | setattr(foo, "__123abc__", None)
|
||||
43 43 | setattr(foo, "abc123", None)
|
||||
44 44 | setattr(foo, r"abc123", None)
|
||||
45 |-setattr(foo.bar, r"baz", None)
|
||||
45 |+foo.bar.baz = None
|
||||
|
||||
|
||||
|
|
|
@ -1,47 +1,39 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: AssertFalse
|
||||
body: "Do not `assert False` (`python -O` removes these calls), raise `AssertionError()`"
|
||||
suggestion: "Replace `assert False`"
|
||||
fixable: true
|
||||
location:
|
||||
row: 8
|
||||
column: 7
|
||||
end_location:
|
||||
row: 8
|
||||
column: 12
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 8
|
||||
column: 0
|
||||
end_location:
|
||||
row: 8
|
||||
column: 12
|
||||
content: raise AssertionError()
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AssertFalse
|
||||
body: "Do not `assert False` (`python -O` removes these calls), raise `AssertionError()`"
|
||||
suggestion: "Replace `assert False`"
|
||||
fixable: true
|
||||
location:
|
||||
row: 10
|
||||
column: 7
|
||||
end_location:
|
||||
row: 10
|
||||
column: 12
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 10
|
||||
column: 0
|
||||
end_location:
|
||||
row: 10
|
||||
column: 23
|
||||
content: "raise AssertionError(\"message\")"
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B011.py:8:8: B011 [*] Do not `assert False` (`python -O` removes these calls), raise `AssertionError()`
|
||||
|
|
||||
8 | assert 1 != 2
|
||||
9 | assert False
|
||||
| ^^^^^ B011
|
||||
10 | assert 1 != 2, "message"
|
||||
11 | assert False, "message"
|
||||
|
|
||||
= help: Replace `assert False`
|
||||
|
||||
ℹ Suggested fix
|
||||
5 5 | """
|
||||
6 6 |
|
||||
7 7 | assert 1 != 2
|
||||
8 |-assert False
|
||||
8 |+raise AssertionError()
|
||||
9 9 | assert 1 != 2, "message"
|
||||
10 10 | assert False, "message"
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B011.py:10:8: B011 [*] Do not `assert False` (`python -O` removes these calls), raise `AssertionError()`
|
||||
|
|
||||
10 | assert False
|
||||
11 | assert 1 != 2, "message"
|
||||
12 | assert False, "message"
|
||||
| ^^^^^ B011
|
||||
|
|
||||
= help: Replace `assert False`
|
||||
|
||||
ℹ Suggested fix
|
||||
7 7 | assert 1 != 2
|
||||
8 8 | assert False
|
||||
9 9 | assert 1 != 2, "message"
|
||||
10 |-assert False, "message"
|
||||
10 |+raise AssertionError("message")
|
||||
|
||||
|
||||
|
|
|
@ -1,159 +1,104 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: JumpStatementInFinally
|
||||
body: "`return` inside `finally` blocks cause exceptions to be silenced"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 8
|
||||
end_location:
|
||||
row: 5
|
||||
column: 14
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: JumpStatementInFinally
|
||||
body: "`return` inside `finally` blocks cause exceptions to be silenced"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 12
|
||||
end_location:
|
||||
row: 13
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: JumpStatementInFinally
|
||||
body: "`return` inside `finally` blocks cause exceptions to be silenced"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 21
|
||||
column: 12
|
||||
end_location:
|
||||
row: 21
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: JumpStatementInFinally
|
||||
body: "`return` inside `finally` blocks cause exceptions to be silenced"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 31
|
||||
column: 12
|
||||
end_location:
|
||||
row: 31
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: JumpStatementInFinally
|
||||
body: "`return` inside `finally` blocks cause exceptions to be silenced"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 44
|
||||
column: 20
|
||||
end_location:
|
||||
row: 44
|
||||
column: 26
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: JumpStatementInFinally
|
||||
body: "`break` inside `finally` blocks cause exceptions to be silenced"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 66
|
||||
column: 12
|
||||
end_location:
|
||||
row: 66
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: JumpStatementInFinally
|
||||
body: "`continue` inside `finally` blocks cause exceptions to be silenced"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 78
|
||||
column: 12
|
||||
end_location:
|
||||
row: 78
|
||||
column: 20
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: JumpStatementInFinally
|
||||
body: "`return` inside `finally` blocks cause exceptions to be silenced"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 94
|
||||
column: 12
|
||||
end_location:
|
||||
row: 94
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: JumpStatementInFinally
|
||||
body: "`continue` inside `finally` blocks cause exceptions to be silenced"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 101
|
||||
column: 8
|
||||
end_location:
|
||||
row: 101
|
||||
column: 16
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: JumpStatementInFinally
|
||||
body: "`break` inside `finally` blocks cause exceptions to be silenced"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 107
|
||||
column: 8
|
||||
end_location:
|
||||
row: 107
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: JumpStatementInFinally
|
||||
body: "`break` inside `finally` blocks cause exceptions to be silenced"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 118
|
||||
column: 16
|
||||
end_location:
|
||||
row: 118
|
||||
column: 21
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B012.py:5:9: B012 `return` inside `finally` blocks cause exceptions to be silenced
|
||||
|
|
||||
5 | pass
|
||||
6 | finally:
|
||||
7 | return # warning
|
||||
| ^^^^^^ B012
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B012.py:13:13: B012 `return` inside `finally` blocks cause exceptions to be silenced
|
||||
|
|
||||
13 | finally:
|
||||
14 | if 1 + 0 == 2 - 1:
|
||||
15 | return # warning
|
||||
| ^^^^^^ B012
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B012.py:21:13: B012 `return` inside `finally` blocks cause exceptions to be silenced
|
||||
|
|
||||
21 | finally:
|
||||
22 | try:
|
||||
23 | return # warning
|
||||
| ^^^^^^ B012
|
||||
24 | except Exception:
|
||||
25 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B012.py:31:13: B012 `return` inside `finally` blocks cause exceptions to be silenced
|
||||
|
|
||||
31 | pass
|
||||
32 | finally:
|
||||
33 | return # warning
|
||||
| ^^^^^^ B012
|
||||
34 | finally:
|
||||
35 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B012.py:44:21: B012 `return` inside `finally` blocks cause exceptions to be silenced
|
||||
|
|
||||
44 | pass
|
||||
45 | finally:
|
||||
46 | return # warning
|
||||
| ^^^^^^ B012
|
||||
47 |
|
||||
48 | finally:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B012.py:66:13: B012 `break` inside `finally` blocks cause exceptions to be silenced
|
||||
|
|
||||
66 | pass
|
||||
67 | finally:
|
||||
68 | break # warning
|
||||
| ^^^^^ B012
|
||||
69 |
|
||||
70 | def j():
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B012.py:78:13: B012 `continue` inside `finally` blocks cause exceptions to be silenced
|
||||
|
|
||||
78 | pass
|
||||
79 | finally:
|
||||
80 | continue # warning
|
||||
| ^^^^^^^^ B012
|
||||
81 |
|
||||
82 | def j():
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B012.py:94:13: B012 `return` inside `finally` blocks cause exceptions to be silenced
|
||||
|
|
||||
94 | continue # no warning
|
||||
95 | while True:
|
||||
96 | return # warning
|
||||
| ^^^^^^ B012
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B012.py:101:9: B012 `continue` inside `finally` blocks cause exceptions to be silenced
|
||||
|
|
||||
101 | pass
|
||||
102 | finally:
|
||||
103 | continue # warning
|
||||
| ^^^^^^^^ B012
|
||||
104 |
|
||||
105 | while True:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B012.py:107:9: B012 `break` inside `finally` blocks cause exceptions to be silenced
|
||||
|
|
||||
107 | pass
|
||||
108 | finally:
|
||||
109 | break # warning
|
||||
| ^^^^^ B012
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B012.py:118:17: B012 `break` inside `finally` blocks cause exceptions to be silenced
|
||||
|
|
||||
118 | y = 0
|
||||
119 | case 0, *x:
|
||||
120 | break # warning
|
||||
| ^^^^^ B012
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,26 +1,24 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: RedundantTupleInExceptionHandler
|
||||
body: "A length-one tuple literal is redundant. Write `except ValueError` instead of `except (ValueError,)`."
|
||||
suggestion: "Replace with `except ValueError`"
|
||||
fixable: true
|
||||
location:
|
||||
row: 3
|
||||
column: 7
|
||||
end_location:
|
||||
row: 3
|
||||
column: 20
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 3
|
||||
column: 7
|
||||
end_location:
|
||||
row: 3
|
||||
column: 20
|
||||
content: ValueError
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B013.py:3:8: B013 [*] A length-one tuple literal is redundant. Write `except ValueError` instead of `except (ValueError,)`.
|
||||
|
|
||||
3 | try:
|
||||
4 | pass
|
||||
5 | except (ValueError,):
|
||||
| ^^^^^^^^^^^^^ B013
|
||||
6 | pass
|
||||
7 | except AttributeError:
|
||||
|
|
||||
= help: Replace with `except ValueError`
|
||||
|
||||
ℹ Suggested fix
|
||||
1 1 | try:
|
||||
2 2 | pass
|
||||
3 |-except (ValueError,):
|
||||
3 |+except ValueError:
|
||||
4 4 | pass
|
||||
5 5 | except AttributeError:
|
||||
6 6 | pass
|
||||
|
||||
|
||||
|
|
|
@ -1,68 +1,67 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: DuplicateHandlerException
|
||||
body: "Exception handler with duplicate exception: `OSError`"
|
||||
suggestion: De-duplicate exceptions
|
||||
fixable: true
|
||||
location:
|
||||
row: 17
|
||||
column: 7
|
||||
end_location:
|
||||
row: 17
|
||||
column: 25
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 17
|
||||
column: 7
|
||||
end_location:
|
||||
row: 17
|
||||
column: 25
|
||||
content: OSError
|
||||
parent: ~
|
||||
- kind:
|
||||
name: DuplicateHandlerException
|
||||
body: "Exception handler with duplicate exception: `MyError`"
|
||||
suggestion: De-duplicate exceptions
|
||||
fixable: true
|
||||
location:
|
||||
row: 28
|
||||
column: 7
|
||||
end_location:
|
||||
row: 28
|
||||
column: 25
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 28
|
||||
column: 7
|
||||
end_location:
|
||||
row: 28
|
||||
column: 25
|
||||
content: MyError
|
||||
parent: ~
|
||||
- kind:
|
||||
name: DuplicateHandlerException
|
||||
body: "Exception handler with duplicate exception: `re.error`"
|
||||
suggestion: De-duplicate exceptions
|
||||
fixable: true
|
||||
location:
|
||||
row: 49
|
||||
column: 7
|
||||
end_location:
|
||||
row: 49
|
||||
column: 27
|
||||
fix:
|
||||
edits:
|
||||
- location:
|
||||
row: 49
|
||||
column: 7
|
||||
end_location:
|
||||
row: 49
|
||||
column: 27
|
||||
content: re.error
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B014.py:17:8: B014 [*] Exception handler with duplicate exception: `OSError`
|
||||
|
|
||||
17 | try:
|
||||
18 | pass
|
||||
19 | except (OSError, OSError) as err:
|
||||
| ^^^^^^^^^^^^^^^^^^ B014
|
||||
20 | # Duplicate exception types are useless
|
||||
21 | pass
|
||||
|
|
||||
= help: De-duplicate exceptions
|
||||
|
||||
ℹ Suggested fix
|
||||
14 14 |
|
||||
15 15 | try:
|
||||
16 16 | pass
|
||||
17 |-except (OSError, OSError) as err:
|
||||
17 |+except OSError as err:
|
||||
18 18 | # Duplicate exception types are useless
|
||||
19 19 | pass
|
||||
20 20 |
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B014.py:28:8: B014 [*] Exception handler with duplicate exception: `MyError`
|
||||
|
|
||||
28 | try:
|
||||
29 | pass
|
||||
30 | except (MyError, MyError):
|
||||
| ^^^^^^^^^^^^^^^^^^ B014
|
||||
31 | # Detect duplicate non-builtin errors
|
||||
32 | pass
|
||||
|
|
||||
= help: De-duplicate exceptions
|
||||
|
||||
ℹ Suggested fix
|
||||
25 25 |
|
||||
26 26 | try:
|
||||
27 27 | pass
|
||||
28 |-except (MyError, MyError):
|
||||
28 |+except MyError:
|
||||
29 29 | # Detect duplicate non-builtin errors
|
||||
30 30 | pass
|
||||
31 31 |
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B014.py:49:8: B014 [*] Exception handler with duplicate exception: `re.error`
|
||||
|
|
||||
49 | try:
|
||||
50 | pass
|
||||
51 | except (re.error, re.error):
|
||||
| ^^^^^^^^^^^^^^^^^^^^ B014
|
||||
52 | # Duplicate exception types as attributes
|
||||
53 | pass
|
||||
|
|
||||
= help: De-duplicate exceptions
|
||||
|
||||
ℹ Suggested fix
|
||||
46 46 |
|
||||
47 47 | try:
|
||||
48 48 | pass
|
||||
49 |-except (re.error, re.error):
|
||||
49 |+except re.error:
|
||||
50 50 | # Duplicate exception types as attributes
|
||||
51 51 | pass
|
||||
52 52 |
|
||||
|
||||
|
||||
|
|
|
@ -1,61 +1,37 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: UselessComparison
|
||||
body: "Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it."
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 3
|
||||
column: 0
|
||||
end_location:
|
||||
row: 3
|
||||
column: 6
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessComparison
|
||||
body: "Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it."
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 7
|
||||
column: 0
|
||||
end_location:
|
||||
row: 7
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessComparison
|
||||
body: "Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it."
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 17
|
||||
column: 4
|
||||
end_location:
|
||||
row: 17
|
||||
column: 15
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessComparison
|
||||
body: "Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it."
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 24
|
||||
column: 4
|
||||
end_location:
|
||||
row: 24
|
||||
column: 10
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B015.py:3:1: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
|
||||
|
|
||||
3 | assert 1 == 1
|
||||
4 |
|
||||
5 | 1 == 1
|
||||
| ^^^^^^ B015
|
||||
6 |
|
||||
7 | assert 1 in (1, 2)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B015.py:7:1: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
|
||||
|
|
||||
7 | assert 1 in (1, 2)
|
||||
8 |
|
||||
9 | 1 in (1, 2)
|
||||
| ^^^^^^^^^^^ B015
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B015.py:17:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
|
||||
|
|
||||
17 | assert 1 in (1, 2)
|
||||
18 |
|
||||
19 | 1 in (1, 2)
|
||||
| ^^^^^^^^^^^ B015
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B015.py:24:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
|
||||
|
|
||||
24 | class TestClass:
|
||||
25 | 1 == 1
|
||||
| ^^^^^^ B015
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,47 +1,33 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: CannotRaiseLiteral
|
||||
body: Cannot raise a literal. Did you intend to return it or raise an Exception?
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 6
|
||||
column: 6
|
||||
end_location:
|
||||
row: 6
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: CannotRaiseLiteral
|
||||
body: Cannot raise a literal. Did you intend to return it or raise an Exception?
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 7
|
||||
column: 6
|
||||
end_location:
|
||||
row: 7
|
||||
column: 7
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: CannotRaiseLiteral
|
||||
body: Cannot raise a literal. Did you intend to return it or raise an Exception?
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 6
|
||||
end_location:
|
||||
row: 8
|
||||
column: 14
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B016.py:6:7: B016 Cannot raise a literal. Did you intend to return it or raise an Exception?
|
||||
|
|
||||
6 | """
|
||||
7 |
|
||||
8 | raise False
|
||||
| ^^^^^ B016
|
||||
9 | raise 1
|
||||
10 | raise "string"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B016.py:7:7: B016 Cannot raise a literal. Did you intend to return it or raise an Exception?
|
||||
|
|
||||
7 | raise False
|
||||
8 | raise 1
|
||||
| ^ B016
|
||||
9 | raise "string"
|
||||
10 | raise Exception(False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B016.py:8:7: B016 Cannot raise a literal. Did you intend to return it or raise an Exception?
|
||||
|
|
||||
8 | raise False
|
||||
9 | raise 1
|
||||
10 | raise "string"
|
||||
| ^^^^^^^^ B016
|
||||
11 | raise Exception(False)
|
||||
12 | raise Exception(1)
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: AssertRaisesException
|
||||
body: "`assertRaises(Exception)` should be considered evil"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 22
|
||||
column: 8
|
||||
end_location:
|
||||
row: 23
|
||||
column: 42
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B017.py:22:9: B017 `assertRaises(Exception)` should be considered evil
|
||||
|
|
||||
22 | class Foobar(unittest.TestCase):
|
||||
23 | def evil_raises(self) -> None:
|
||||
24 | with self.assertRaises(Exception):
|
||||
| _________^
|
||||
25 | | raise Exception("Evil I say!")
|
||||
| |__________________________________________^ B017
|
||||
26 |
|
||||
27 | def context_manager_raises(self) -> None:
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,383 +1,258 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 11
|
||||
column: 4
|
||||
end_location:
|
||||
row: 11
|
||||
column: 6
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 12
|
||||
column: 4
|
||||
end_location:
|
||||
row: 12
|
||||
column: 5
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 4
|
||||
end_location:
|
||||
row: 13
|
||||
column: 7
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 14
|
||||
column: 4
|
||||
end_location:
|
||||
row: 14
|
||||
column: 10
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 15
|
||||
column: 4
|
||||
end_location:
|
||||
row: 15
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 16
|
||||
column: 4
|
||||
end_location:
|
||||
row: 16
|
||||
column: 9
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 17
|
||||
column: 4
|
||||
end_location:
|
||||
row: 17
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 18
|
||||
column: 4
|
||||
end_location:
|
||||
row: 18
|
||||
column: 10
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 19
|
||||
column: 4
|
||||
end_location:
|
||||
row: 19
|
||||
column: 10
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 20
|
||||
column: 4
|
||||
end_location:
|
||||
row: 20
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 24
|
||||
column: 4
|
||||
end_location:
|
||||
row: 24
|
||||
column: 7
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 27
|
||||
column: 4
|
||||
end_location:
|
||||
row: 27
|
||||
column: 5
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 39
|
||||
column: 4
|
||||
end_location:
|
||||
row: 39
|
||||
column: 6
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 40
|
||||
column: 4
|
||||
end_location:
|
||||
row: 40
|
||||
column: 5
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 41
|
||||
column: 4
|
||||
end_location:
|
||||
row: 41
|
||||
column: 7
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 42
|
||||
column: 4
|
||||
end_location:
|
||||
row: 42
|
||||
column: 10
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 43
|
||||
column: 4
|
||||
end_location:
|
||||
row: 43
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 44
|
||||
column: 4
|
||||
end_location:
|
||||
row: 44
|
||||
column: 9
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 45
|
||||
column: 4
|
||||
end_location:
|
||||
row: 45
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 46
|
||||
column: 4
|
||||
end_location:
|
||||
row: 46
|
||||
column: 10
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 47
|
||||
column: 4
|
||||
end_location:
|
||||
row: 47
|
||||
column: 10
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 48
|
||||
column: 4
|
||||
end_location:
|
||||
row: 48
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 52
|
||||
column: 4
|
||||
end_location:
|
||||
row: 52
|
||||
column: 7
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 55
|
||||
column: 4
|
||||
end_location:
|
||||
row: 55
|
||||
column: 5
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 63
|
||||
column: 4
|
||||
end_location:
|
||||
row: 63
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless attribute access. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 64
|
||||
column: 4
|
||||
end_location:
|
||||
row: 64
|
||||
column: 22
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessExpression
|
||||
body: Found useless expression. Either assign it to a variable or remove it.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 65
|
||||
column: 4
|
||||
end_location:
|
||||
row: 65
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:11:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
11 | "str" # Str (no raise)
|
||||
12 | f"{int}" # JoinedStr (no raise)
|
||||
13 | 1j # Number (complex)
|
||||
| ^^ B018
|
||||
14 | 1 # Number (int)
|
||||
15 | 1.0 # Number (float)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:12:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
12 | f"{int}" # JoinedStr (no raise)
|
||||
13 | 1j # Number (complex)
|
||||
14 | 1 # Number (int)
|
||||
| ^ B018
|
||||
15 | 1.0 # Number (float)
|
||||
16 | b"foo" # Binary
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:13:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
13 | 1j # Number (complex)
|
||||
14 | 1 # Number (int)
|
||||
15 | 1.0 # Number (float)
|
||||
| ^^^ B018
|
||||
16 | b"foo" # Binary
|
||||
17 | True # NameConstant (True)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:14:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
14 | 1 # Number (int)
|
||||
15 | 1.0 # Number (float)
|
||||
16 | b"foo" # Binary
|
||||
| ^^^^^^ B018
|
||||
17 | True # NameConstant (True)
|
||||
18 | False # NameConstant (False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:15:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
15 | 1.0 # Number (float)
|
||||
16 | b"foo" # Binary
|
||||
17 | True # NameConstant (True)
|
||||
| ^^^^ B018
|
||||
18 | False # NameConstant (False)
|
||||
19 | None # NameConstant (None)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:16:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
16 | b"foo" # Binary
|
||||
17 | True # NameConstant (True)
|
||||
18 | False # NameConstant (False)
|
||||
| ^^^^^ B018
|
||||
19 | None # NameConstant (None)
|
||||
20 | [1, 2] # list
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:17:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
17 | True # NameConstant (True)
|
||||
18 | False # NameConstant (False)
|
||||
19 | None # NameConstant (None)
|
||||
| ^^^^ B018
|
||||
20 | [1, 2] # list
|
||||
21 | {1, 2} # set
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:18:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
18 | False # NameConstant (False)
|
||||
19 | None # NameConstant (None)
|
||||
20 | [1, 2] # list
|
||||
| ^^^^^^ B018
|
||||
21 | {1, 2} # set
|
||||
22 | {"foo": "bar"} # dict
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:19:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
19 | None # NameConstant (None)
|
||||
20 | [1, 2] # list
|
||||
21 | {1, 2} # set
|
||||
| ^^^^^^ B018
|
||||
22 | {"foo": "bar"} # dict
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:20:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
20 | [1, 2] # list
|
||||
21 | {1, 2} # set
|
||||
22 | {"foo": "bar"} # dict
|
||||
| ^^^^^^^^^^^^^^ B018
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:24:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
24 | class Foo3:
|
||||
25 | 123
|
||||
| ^^^ B018
|
||||
26 | a = 2
|
||||
27 | "str"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:27:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
27 | a = 2
|
||||
28 | "str"
|
||||
29 | 1
|
||||
| ^ B018
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:39:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
39 | "str" # Str (no raise)
|
||||
40 | f"{int}" # JoinedStr (no raise)
|
||||
41 | 1j # Number (complex)
|
||||
| ^^ B018
|
||||
42 | 1 # Number (int)
|
||||
43 | 1.0 # Number (float)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:40:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
40 | f"{int}" # JoinedStr (no raise)
|
||||
41 | 1j # Number (complex)
|
||||
42 | 1 # Number (int)
|
||||
| ^ B018
|
||||
43 | 1.0 # Number (float)
|
||||
44 | b"foo" # Binary
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:41:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
41 | 1j # Number (complex)
|
||||
42 | 1 # Number (int)
|
||||
43 | 1.0 # Number (float)
|
||||
| ^^^ B018
|
||||
44 | b"foo" # Binary
|
||||
45 | True # NameConstant (True)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:42:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
42 | 1 # Number (int)
|
||||
43 | 1.0 # Number (float)
|
||||
44 | b"foo" # Binary
|
||||
| ^^^^^^ B018
|
||||
45 | True # NameConstant (True)
|
||||
46 | False # NameConstant (False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:43:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
43 | 1.0 # Number (float)
|
||||
44 | b"foo" # Binary
|
||||
45 | True # NameConstant (True)
|
||||
| ^^^^ B018
|
||||
46 | False # NameConstant (False)
|
||||
47 | None # NameConstant (None)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:44:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
44 | b"foo" # Binary
|
||||
45 | True # NameConstant (True)
|
||||
46 | False # NameConstant (False)
|
||||
| ^^^^^ B018
|
||||
47 | None # NameConstant (None)
|
||||
48 | [1, 2] # list
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:45:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
45 | True # NameConstant (True)
|
||||
46 | False # NameConstant (False)
|
||||
47 | None # NameConstant (None)
|
||||
| ^^^^ B018
|
||||
48 | [1, 2] # list
|
||||
49 | {1, 2} # set
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:46:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
46 | False # NameConstant (False)
|
||||
47 | None # NameConstant (None)
|
||||
48 | [1, 2] # list
|
||||
| ^^^^^^ B018
|
||||
49 | {1, 2} # set
|
||||
50 | {"foo": "bar"} # dict
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:47:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
47 | None # NameConstant (None)
|
||||
48 | [1, 2] # list
|
||||
49 | {1, 2} # set
|
||||
| ^^^^^^ B018
|
||||
50 | {"foo": "bar"} # dict
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:48:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
48 | [1, 2] # list
|
||||
49 | {1, 2} # set
|
||||
50 | {"foo": "bar"} # dict
|
||||
| ^^^^^^^^^^^^^^ B018
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:52:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
52 | def foo3():
|
||||
53 | 123
|
||||
| ^^^ B018
|
||||
54 | a = 2
|
||||
55 | "str"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:55:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
55 | a = 2
|
||||
56 | "str"
|
||||
57 | 3
|
||||
| ^ B018
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:63:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
63 | def foo5():
|
||||
64 | foo.bar # Attribute (raise)
|
||||
| ^^^^^^^ B018
|
||||
65 | object().__class__ # Attribute (raise)
|
||||
66 | "foo" + "bar" # BinOp (raise)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:64:5: B018 Found useless attribute access. Either assign it to a variable or remove it.
|
||||
|
|
||||
64 | def foo5():
|
||||
65 | foo.bar # Attribute (raise)
|
||||
66 | object().__class__ # Attribute (raise)
|
||||
| ^^^^^^^^^^^^^^^^^^ B018
|
||||
67 | "foo" + "bar" # BinOp (raise)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B018.py:65:5: B018 Found useless expression. Either assign it to a variable or remove it.
|
||||
|
|
||||
65 | foo.bar # Attribute (raise)
|
||||
66 | object().__class__ # Attribute (raise)
|
||||
67 | "foo" + "bar" # BinOp (raise)
|
||||
| ^^^^^^^^^^^^^ B018
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,117 +1,83 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: CachedInstanceMethod
|
||||
body: "Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 78
|
||||
column: 5
|
||||
end_location:
|
||||
row: 78
|
||||
column: 20
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: CachedInstanceMethod
|
||||
body: "Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 82
|
||||
column: 5
|
||||
end_location:
|
||||
row: 82
|
||||
column: 10
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: CachedInstanceMethod
|
||||
body: "Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 86
|
||||
column: 5
|
||||
end_location:
|
||||
row: 86
|
||||
column: 22
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: CachedInstanceMethod
|
||||
body: "Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 90
|
||||
column: 5
|
||||
end_location:
|
||||
row: 90
|
||||
column: 12
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: CachedInstanceMethod
|
||||
body: "Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 94
|
||||
column: 5
|
||||
end_location:
|
||||
row: 94
|
||||
column: 24
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: CachedInstanceMethod
|
||||
body: "Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 98
|
||||
column: 5
|
||||
end_location:
|
||||
row: 98
|
||||
column: 14
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: CachedInstanceMethod
|
||||
body: "Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 102
|
||||
column: 5
|
||||
end_location:
|
||||
row: 102
|
||||
column: 26
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: CachedInstanceMethod
|
||||
body: "Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 106
|
||||
column: 5
|
||||
end_location:
|
||||
row: 106
|
||||
column: 16
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B019.py:78:6: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks
|
||||
|
|
||||
78 | # Remaining methods should emit B019
|
||||
79 | @functools.cache
|
||||
| ^^^^^^^^^^^^^^^ B019
|
||||
80 | def cached_instance_method(self, y):
|
||||
81 | ...
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B019.py:82:6: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks
|
||||
|
|
||||
82 | ...
|
||||
83 |
|
||||
84 | @cache
|
||||
| ^^^^^ B019
|
||||
85 | def another_cached_instance_method(self, y):
|
||||
86 | ...
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B019.py:86:6: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks
|
||||
|
|
||||
86 | ...
|
||||
87 |
|
||||
88 | @functools.cache()
|
||||
| ^^^^^^^^^^^^^^^^^ B019
|
||||
89 | def called_cached_instance_method(self, y):
|
||||
90 | ...
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B019.py:90:6: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks
|
||||
|
|
||||
90 | ...
|
||||
91 |
|
||||
92 | @cache()
|
||||
| ^^^^^^^ B019
|
||||
93 | def another_called_cached_instance_method(self, y):
|
||||
94 | ...
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B019.py:94:6: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks
|
||||
|
|
||||
94 | ...
|
||||
95 |
|
||||
96 | @functools.lru_cache
|
||||
| ^^^^^^^^^^^^^^^^^^^ B019
|
||||
97 | def lru_cached_instance_method(self, y):
|
||||
98 | ...
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B019.py:98:6: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks
|
||||
|
|
||||
98 | ...
|
||||
99 |
|
||||
100 | @lru_cache
|
||||
| ^^^^^^^^^ B019
|
||||
101 | def another_lru_cached_instance_method(self, y):
|
||||
102 | ...
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B019.py:102:6: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks
|
||||
|
|
||||
102 | ...
|
||||
103 |
|
||||
104 | @functools.lru_cache()
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ B019
|
||||
105 | def called_lru_cached_instance_method(self, y):
|
||||
106 | ...
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B019.py:106:6: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks
|
||||
|
|
||||
106 | ...
|
||||
107 |
|
||||
108 | @lru_cache()
|
||||
| ^^^^^^^^^^^ B019
|
||||
109 | def another_called_lru_cached_instance_method(self, y):
|
||||
110 | ...
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,47 +1,30 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: LoopVariableOverridesIterator
|
||||
body: "Loop control variable `items` overrides iterable it iterates"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 4
|
||||
end_location:
|
||||
row: 8
|
||||
column: 9
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: LoopVariableOverridesIterator
|
||||
body: "Loop control variable `values` overrides iterable it iterates"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 21
|
||||
column: 9
|
||||
end_location:
|
||||
row: 21
|
||||
column: 15
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: LoopVariableOverridesIterator
|
||||
body: "Loop control variable `vars` overrides iterable it iterates"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 36
|
||||
column: 4
|
||||
end_location:
|
||||
row: 36
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B020.py:8:5: B020 Loop control variable `items` overrides iterable it iterates
|
||||
|
|
||||
8 | items = [1, 2, 3]
|
||||
9 |
|
||||
10 | for items in items:
|
||||
| ^^^^^ B020
|
||||
11 | print(items)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B020.py:21:10: B020 Loop control variable `values` overrides iterable it iterates
|
||||
|
|
||||
21 | print(f"{key}, {value}")
|
||||
22 |
|
||||
23 | for key, values in values.items():
|
||||
| ^^^^^^ B020
|
||||
24 | print(f"{key}, {values}")
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B020.py:36:5: B020 Loop control variable `vars` overrides iterable it iterates
|
||||
|
|
||||
36 | # However we still call out reassigning the iterable in the comprehension.
|
||||
37 | for vars in [i for i in vars]:
|
||||
| ^^^^ B020
|
||||
38 | print(vars)
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,145 +1,80 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: FStringDocstring
|
||||
body: f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 1
|
||||
column: 0
|
||||
end_location:
|
||||
row: 4
|
||||
column: 3
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FStringDocstring
|
||||
body: f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 14
|
||||
column: 4
|
||||
end_location:
|
||||
row: 14
|
||||
column: 28
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FStringDocstring
|
||||
body: f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 22
|
||||
column: 4
|
||||
end_location:
|
||||
row: 22
|
||||
column: 28
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FStringDocstring
|
||||
body: f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 30
|
||||
column: 4
|
||||
end_location:
|
||||
row: 30
|
||||
column: 28
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FStringDocstring
|
||||
body: f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 38
|
||||
column: 4
|
||||
end_location:
|
||||
row: 38
|
||||
column: 28
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FStringDocstring
|
||||
body: f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 46
|
||||
column: 4
|
||||
end_location:
|
||||
row: 46
|
||||
column: 24
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FStringDocstring
|
||||
body: f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 54
|
||||
column: 4
|
||||
end_location:
|
||||
row: 54
|
||||
column: 24
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FStringDocstring
|
||||
body: f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 62
|
||||
column: 4
|
||||
end_location:
|
||||
row: 62
|
||||
column: 24
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FStringDocstring
|
||||
body: f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 70
|
||||
column: 4
|
||||
end_location:
|
||||
row: 70
|
||||
column: 24
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FStringDocstring
|
||||
body: f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 74
|
||||
column: 4
|
||||
end_location:
|
||||
row: 74
|
||||
column: 48
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B021.py:1:1: B021 f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
|
|
||||
1 | / f"""
|
||||
2 | | Should emit:
|
||||
3 | | B021 - on lines 14, 22, 30, 38, 46, 54, 62, 70, 73
|
||||
4 | | """
|
||||
| |___^ B021
|
||||
5 |
|
||||
6 | VARIABLE = "world"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B021.py:14:5: B021 f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
|
|
||||
14 | def foo2():
|
||||
15 | f"""hello {VARIABLE}!"""
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ B021
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B021.py:22:5: B021 f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
|
|
||||
22 | class bar2:
|
||||
23 | f"""hello {VARIABLE}!"""
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ B021
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B021.py:30:5: B021 f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
|
|
||||
30 | def foo2():
|
||||
31 | f"""hello {VARIABLE}!"""
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ B021
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B021.py:38:5: B021 f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
|
|
||||
38 | class bar2:
|
||||
39 | f"""hello {VARIABLE}!"""
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ B021
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B021.py:46:5: B021 f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
|
|
||||
46 | def foo2():
|
||||
47 | f"hello {VARIABLE}!"
|
||||
| ^^^^^^^^^^^^^^^^^^^^ B021
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B021.py:54:5: B021 f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
|
|
||||
54 | class bar2:
|
||||
55 | f"hello {VARIABLE}!"
|
||||
| ^^^^^^^^^^^^^^^^^^^^ B021
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B021.py:62:5: B021 f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
|
|
||||
62 | def foo2():
|
||||
63 | f"hello {VARIABLE}!"
|
||||
| ^^^^^^^^^^^^^^^^^^^^ B021
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B021.py:70:5: B021 f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
|
|
||||
70 | class bar2:
|
||||
71 | f"hello {VARIABLE}!"
|
||||
| ^^^^^^^^^^^^^^^^^^^^ B021
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B021.py:74:5: B021 f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.
|
||||
|
|
||||
74 | def baz():
|
||||
75 | f"""I'm probably a docstring: {VARIABLE}!"""
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B021
|
||||
76 | print(f"""I'm a normal string""")
|
||||
77 | f"""Don't detect me!"""
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,33 +1,22 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: UselessContextlibSuppress
|
||||
body: "No arguments passed to `contextlib.suppress`. No exceptions will be suppressed and therefore this context manager is redundant"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 9
|
||||
column: 5
|
||||
end_location:
|
||||
row: 9
|
||||
column: 26
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UselessContextlibSuppress
|
||||
body: "No arguments passed to `contextlib.suppress`. No exceptions will be suppressed and therefore this context manager is redundant"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 12
|
||||
column: 5
|
||||
end_location:
|
||||
row: 12
|
||||
column: 15
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B022.py:9:6: B022 No arguments passed to `contextlib.suppress`. No exceptions will be suppressed and therefore this context manager is redundant
|
||||
|
|
||||
9 | from contextlib import suppress
|
||||
10 |
|
||||
11 | with contextlib.suppress():
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ B022
|
||||
12 | raise ValueError
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B022.py:12:6: B022 No arguments passed to `contextlib.suppress`. No exceptions will be suppressed and therefore this context manager is redundant
|
||||
|
|
||||
12 | raise ValueError
|
||||
13 |
|
||||
14 | with suppress():
|
||||
| ^^^^^^^^^^ B022
|
||||
15 | raise ValueError
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,341 +1,224 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `x`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 12
|
||||
column: 29
|
||||
end_location:
|
||||
row: 12
|
||||
column: 30
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `y`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 29
|
||||
end_location:
|
||||
row: 13
|
||||
column: 30
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `x`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 16
|
||||
column: 15
|
||||
end_location:
|
||||
row: 16
|
||||
column: 16
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `x`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 28
|
||||
column: 18
|
||||
end_location:
|
||||
row: 28
|
||||
column: 19
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `x`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 29
|
||||
column: 18
|
||||
end_location:
|
||||
row: 29
|
||||
column: 19
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `x`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 30
|
||||
column: 18
|
||||
end_location:
|
||||
row: 30
|
||||
column: 19
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `x`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 31
|
||||
column: 21
|
||||
end_location:
|
||||
row: 31
|
||||
column: 22
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `x`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 40
|
||||
column: 33
|
||||
end_location:
|
||||
row: 40
|
||||
column: 34
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `x`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 42
|
||||
column: 13
|
||||
end_location:
|
||||
row: 42
|
||||
column: 14
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `a`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 50
|
||||
column: 29
|
||||
end_location:
|
||||
row: 50
|
||||
column: 30
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `a_`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 51
|
||||
column: 29
|
||||
end_location:
|
||||
row: 51
|
||||
column: 31
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `b`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 52
|
||||
column: 29
|
||||
end_location:
|
||||
row: 52
|
||||
column: 30
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `c`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 53
|
||||
column: 29
|
||||
end_location:
|
||||
row: 53
|
||||
column: 30
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `j`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 61
|
||||
column: 16
|
||||
end_location:
|
||||
row: 61
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `k`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 61
|
||||
column: 20
|
||||
end_location:
|
||||
row: 61
|
||||
column: 21
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `l`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 68
|
||||
column: 9
|
||||
end_location:
|
||||
row: 68
|
||||
column: 10
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `i`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 82
|
||||
column: 15
|
||||
end_location:
|
||||
row: 82
|
||||
column: 16
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `x`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 117
|
||||
column: 23
|
||||
end_location:
|
||||
row: 117
|
||||
column: 24
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `x`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 118
|
||||
column: 26
|
||||
end_location:
|
||||
row: 118
|
||||
column: 27
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `x`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 119
|
||||
column: 36
|
||||
end_location:
|
||||
row: 119
|
||||
column: 37
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `x`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 120
|
||||
column: 37
|
||||
end_location:
|
||||
row: 120
|
||||
column: 38
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `x`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 121
|
||||
column: 36
|
||||
end_location:
|
||||
row: 121
|
||||
column: 37
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `name`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 171
|
||||
column: 28
|
||||
end_location:
|
||||
row: 171
|
||||
column: 32
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: FunctionUsesLoopVariable
|
||||
body: "Function definition does not bind loop variable `i`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 174
|
||||
column: 28
|
||||
end_location:
|
||||
row: 174
|
||||
column: 29
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:12:30: B023 Function definition does not bind loop variable `x`
|
||||
|
|
||||
12 | y = x + 1
|
||||
13 | # Subject to late-binding problems
|
||||
14 | functions.append(lambda: x)
|
||||
| ^ B023
|
||||
15 | functions.append(lambda: y) # not just the loop var
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:13:30: B023 Function definition does not bind loop variable `y`
|
||||
|
|
||||
13 | # Subject to late-binding problems
|
||||
14 | functions.append(lambda: x)
|
||||
15 | functions.append(lambda: y) # not just the loop var
|
||||
| ^ B023
|
||||
16 |
|
||||
17 | def f_bad_1():
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:16:16: B023 Function definition does not bind loop variable `x`
|
||||
|
|
||||
16 | def f_bad_1():
|
||||
17 | return x
|
||||
| ^ B023
|
||||
18 |
|
||||
19 | # Actually OK
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:28:19: B023 Function definition does not bind loop variable `x`
|
||||
|
|
||||
28 | def check_inside_functions_too():
|
||||
29 | ls = [lambda: x for x in range(2)] # error
|
||||
| ^ B023
|
||||
30 | st = {lambda: x for x in range(2)} # error
|
||||
31 | gn = (lambda: x for x in range(2)) # error
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:29:19: B023 Function definition does not bind loop variable `x`
|
||||
|
|
||||
29 | def check_inside_functions_too():
|
||||
30 | ls = [lambda: x for x in range(2)] # error
|
||||
31 | st = {lambda: x for x in range(2)} # error
|
||||
| ^ B023
|
||||
32 | gn = (lambda: x for x in range(2)) # error
|
||||
33 | dt = {x: lambda: x for x in range(2)} # error
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:30:19: B023 Function definition does not bind loop variable `x`
|
||||
|
|
||||
30 | ls = [lambda: x for x in range(2)] # error
|
||||
31 | st = {lambda: x for x in range(2)} # error
|
||||
32 | gn = (lambda: x for x in range(2)) # error
|
||||
| ^ B023
|
||||
33 | dt = {x: lambda: x for x in range(2)} # error
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:31:22: B023 Function definition does not bind loop variable `x`
|
||||
|
|
||||
31 | st = {lambda: x for x in range(2)} # error
|
||||
32 | gn = (lambda: x for x in range(2)) # error
|
||||
33 | dt = {x: lambda: x for x in range(2)} # error
|
||||
| ^ B023
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:40:34: B023 Function definition does not bind loop variable `x`
|
||||
|
|
||||
40 | async def container_for_problems():
|
||||
41 | async for x in pointless_async_iterable():
|
||||
42 | functions.append(lambda: x) # error
|
||||
| ^ B023
|
||||
43 |
|
||||
44 | [lambda: x async for x in pointless_async_iterable()] # error
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:42:14: B023 Function definition does not bind loop variable `x`
|
||||
|
|
||||
42 | functions.append(lambda: x) # error
|
||||
43 |
|
||||
44 | [lambda: x async for x in pointless_async_iterable()] # error
|
||||
| ^ B023
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:50:30: B023 Function definition does not bind loop variable `a`
|
||||
|
|
||||
50 | a = a_ = a - 1
|
||||
51 | b += 1
|
||||
52 | functions.append(lambda: a) # error
|
||||
| ^ B023
|
||||
53 | functions.append(lambda: a_) # error
|
||||
54 | functions.append(lambda: b) # error
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:51:30: B023 Function definition does not bind loop variable `a_`
|
||||
|
|
||||
51 | b += 1
|
||||
52 | functions.append(lambda: a) # error
|
||||
53 | functions.append(lambda: a_) # error
|
||||
| ^^ B023
|
||||
54 | functions.append(lambda: b) # error
|
||||
55 | functions.append(lambda: c) # error, but not a name error due to late binding
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:52:30: B023 Function definition does not bind loop variable `b`
|
||||
|
|
||||
52 | functions.append(lambda: a) # error
|
||||
53 | functions.append(lambda: a_) # error
|
||||
54 | functions.append(lambda: b) # error
|
||||
| ^ B023
|
||||
55 | functions.append(lambda: c) # error, but not a name error due to late binding
|
||||
56 | c: bool = a > 3
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:53:30: B023 Function definition does not bind loop variable `c`
|
||||
|
|
||||
53 | functions.append(lambda: a_) # error
|
||||
54 | functions.append(lambda: b) # error
|
||||
55 | functions.append(lambda: c) # error, but not a name error due to late binding
|
||||
| ^ B023
|
||||
56 | c: bool = a > 3
|
||||
57 | if not c:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:61:17: B023 Function definition does not bind loop variable `j`
|
||||
|
|
||||
61 | for j in range(2):
|
||||
62 | for k in range(3):
|
||||
63 | lambda: j * k # error
|
||||
| ^ B023
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:61:21: B023 Function definition does not bind loop variable `k`
|
||||
|
|
||||
61 | for j in range(2):
|
||||
62 | for k in range(3):
|
||||
63 | lambda: j * k # error
|
||||
| ^ B023
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:68:10: B023 Function definition does not bind loop variable `l`
|
||||
|
|
||||
68 | def f():
|
||||
69 | j = None # OK because it's an assignment
|
||||
70 | [l for k in range(2)] # error for l, not for k
|
||||
| ^ B023
|
||||
71 |
|
||||
72 | assert a and functions
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:82:16: B023 Function definition does not bind loop variable `i`
|
||||
|
|
||||
82 | for i in range(3):
|
||||
83 | lambda: f"{i}"
|
||||
| ^ B023
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:117:24: B023 Function definition does not bind loop variable `x`
|
||||
|
|
||||
117 | for x in range(2):
|
||||
118 | # It's not a complete get-out-of-linting-free construct - these should fail:
|
||||
119 | min([None, lambda: x], key=repr)
|
||||
| ^ B023
|
||||
120 | sorted([None, lambda: x], key=repr)
|
||||
121 | any(filter(bool, [None, lambda: x]))
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:118:27: B023 Function definition does not bind loop variable `x`
|
||||
|
|
||||
118 | # It's not a complete get-out-of-linting-free construct - these should fail:
|
||||
119 | min([None, lambda: x], key=repr)
|
||||
120 | sorted([None, lambda: x], key=repr)
|
||||
| ^ B023
|
||||
121 | any(filter(bool, [None, lambda: x]))
|
||||
122 | list(filter(bool, [None, lambda: x]))
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:119:37: B023 Function definition does not bind loop variable `x`
|
||||
|
|
||||
119 | min([None, lambda: x], key=repr)
|
||||
120 | sorted([None, lambda: x], key=repr)
|
||||
121 | any(filter(bool, [None, lambda: x]))
|
||||
| ^ B023
|
||||
122 | list(filter(bool, [None, lambda: x]))
|
||||
123 | all(reduce(bool, [None, lambda: x]))
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:120:38: B023 Function definition does not bind loop variable `x`
|
||||
|
|
||||
120 | sorted([None, lambda: x], key=repr)
|
||||
121 | any(filter(bool, [None, lambda: x]))
|
||||
122 | list(filter(bool, [None, lambda: x]))
|
||||
| ^ B023
|
||||
123 | all(reduce(bool, [None, lambda: x]))
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:121:37: B023 Function definition does not bind loop variable `x`
|
||||
|
|
||||
121 | any(filter(bool, [None, lambda: x]))
|
||||
122 | list(filter(bool, [None, lambda: x]))
|
||||
123 | all(reduce(bool, [None, lambda: x]))
|
||||
| ^ B023
|
||||
124 |
|
||||
125 | # But all these should be OK:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:171:29: B023 Function definition does not bind loop variable `name`
|
||||
|
|
||||
171 | if foo(name):
|
||||
172 | return [lambda: name] # known false alarm
|
||||
| ^^^^ B023
|
||||
173 |
|
||||
174 | if False:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B023.py:174:29: B023 Function definition does not bind loop variable `i`
|
||||
|
|
||||
174 | if False:
|
||||
175 | return [lambda: i for i in range(3)] # error
|
||||
| ^ B023
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,89 +1,52 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: AbstractBaseClassWithoutAbstractMethod
|
||||
body: "`Base_1` is an abstract base class, but it has no abstract methods"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 18
|
||||
column: 0
|
||||
end_location:
|
||||
row: 20
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AbstractBaseClassWithoutAbstractMethod
|
||||
body: "`MetaBase_1` is an abstract base class, but it has no abstract methods"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 71
|
||||
column: 0
|
||||
end_location:
|
||||
row: 73
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AbstractBaseClassWithoutAbstractMethod
|
||||
body: "`abc_Base_1` is an abstract base class, but it has no abstract methods"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 82
|
||||
column: 0
|
||||
end_location:
|
||||
row: 84
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AbstractBaseClassWithoutAbstractMethod
|
||||
body: "`abc_Base_2` is an abstract base class, but it has no abstract methods"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 87
|
||||
column: 0
|
||||
end_location:
|
||||
row: 89
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AbstractBaseClassWithoutAbstractMethod
|
||||
body: "`notabc_Base_1` is an abstract base class, but it has no abstract methods"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 92
|
||||
column: 0
|
||||
end_location:
|
||||
row: 94
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: AbstractBaseClassWithoutAbstractMethod
|
||||
body: "`abc_set_class_variable_4` is an abstract base class, but it has no abstract methods"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 141
|
||||
column: 0
|
||||
end_location:
|
||||
row: 142
|
||||
column: 7
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B024.py:18:1: B024 `Base_1` is an abstract base class, but it has no abstract methods
|
||||
|
|
||||
18 | / class Base_1(ABC): # error
|
||||
19 | | def method(self):
|
||||
20 | | foo()
|
||||
| |_____________^ B024
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B024.py:71:1: B024 `MetaBase_1` is an abstract base class, but it has no abstract methods
|
||||
|
|
||||
71 | / class MetaBase_1(metaclass=ABCMeta): # error
|
||||
72 | | def method(self):
|
||||
73 | | foo()
|
||||
| |_____________^ B024
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B024.py:82:1: B024 `abc_Base_1` is an abstract base class, but it has no abstract methods
|
||||
|
|
||||
82 | / class abc_Base_1(abc.ABC): # error
|
||||
83 | | def method(self):
|
||||
84 | | foo()
|
||||
| |_____________^ B024
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B024.py:87:1: B024 `abc_Base_2` is an abstract base class, but it has no abstract methods
|
||||
|
|
||||
87 | / class abc_Base_2(metaclass=abc.ABCMeta): # error
|
||||
88 | | def method(self):
|
||||
89 | | foo()
|
||||
| |_____________^ B024
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B024.py:92:1: B024 `notabc_Base_1` is an abstract base class, but it has no abstract methods
|
||||
|
|
||||
92 | / class notabc_Base_1(notabc.ABC): # error
|
||||
93 | | def method(self):
|
||||
94 | | foo()
|
||||
| |_____________^ B024
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B024.py:141:1: B024 `abc_set_class_variable_4` is an abstract base class, but it has no abstract methods
|
||||
|
|
||||
141 | # this doesn't actually declare a class variable, it's just an expression
|
||||
142 | / class abc_set_class_variable_4(ABC): # error
|
||||
143 | | foo
|
||||
| |_______^ B024
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,61 +1,41 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: DuplicateTryBlockException
|
||||
body: "try-except block with duplicate exception `ValueError`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 19
|
||||
column: 7
|
||||
end_location:
|
||||
row: 19
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: DuplicateTryBlockException
|
||||
body: "try-except block with duplicate exception `pickle.PickleError`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 28
|
||||
column: 7
|
||||
end_location:
|
||||
row: 28
|
||||
column: 25
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: DuplicateTryBlockException
|
||||
body: "try-except block with duplicate exception `ValueError`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 35
|
||||
column: 7
|
||||
end_location:
|
||||
row: 35
|
||||
column: 17
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: DuplicateTryBlockException
|
||||
body: "try-except block with duplicate exception `TypeError`"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 37
|
||||
column: 17
|
||||
end_location:
|
||||
row: 37
|
||||
column: 26
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B025.py:19:8: B025 try-except block with duplicate exception `ValueError`
|
||||
|
|
||||
19 | except ValueError:
|
||||
20 | a = 2
|
||||
21 | except ValueError:
|
||||
| ^^^^^^^^^^ B025
|
||||
22 | a = 2
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B025.py:28:8: B025 try-except block with duplicate exception `pickle.PickleError`
|
||||
|
|
||||
28 | except ValueError:
|
||||
29 | a = 2
|
||||
30 | except pickle.PickleError:
|
||||
| ^^^^^^^^^^^^^^^^^^ B025
|
||||
31 | a = 2
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B025.py:35:8: B025 try-except block with duplicate exception `ValueError`
|
||||
|
|
||||
35 | except (ValueError, TypeError):
|
||||
36 | a = 2
|
||||
37 | except ValueError:
|
||||
| ^^^^^^^^^^ B025
|
||||
38 | a = 2
|
||||
39 | except (OSError, TypeError):
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B025.py:37:18: B025 try-except block with duplicate exception `TypeError`
|
||||
|
|
||||
37 | except ValueError:
|
||||
38 | a = 2
|
||||
39 | except (OSError, TypeError):
|
||||
| ^^^^^^^^^ B025
|
||||
40 | a = 2
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,103 +1,70 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: StarArgUnpackingAfterKeywordArg
|
||||
body: Star-arg unpacking after a keyword argument is strongly discouraged
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 16
|
||||
column: 15
|
||||
end_location:
|
||||
row: 16
|
||||
column: 30
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: StarArgUnpackingAfterKeywordArg
|
||||
body: Star-arg unpacking after a keyword argument is strongly discouraged
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 17
|
||||
column: 15
|
||||
end_location:
|
||||
row: 17
|
||||
column: 23
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: StarArgUnpackingAfterKeywordArg
|
||||
body: Star-arg unpacking after a keyword argument is strongly discouraged
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 18
|
||||
column: 26
|
||||
end_location:
|
||||
row: 18
|
||||
column: 34
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: StarArgUnpackingAfterKeywordArg
|
||||
body: Star-arg unpacking after a keyword argument is strongly discouraged
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 19
|
||||
column: 37
|
||||
end_location:
|
||||
row: 19
|
||||
column: 40
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: StarArgUnpackingAfterKeywordArg
|
||||
body: Star-arg unpacking after a keyword argument is strongly discouraged
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 20
|
||||
column: 15
|
||||
end_location:
|
||||
row: 20
|
||||
column: 23
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: StarArgUnpackingAfterKeywordArg
|
||||
body: Star-arg unpacking after a keyword argument is strongly discouraged
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 20
|
||||
column: 25
|
||||
end_location:
|
||||
row: 20
|
||||
column: 33
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: StarArgUnpackingAfterKeywordArg
|
||||
body: Star-arg unpacking after a keyword argument is strongly discouraged
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 21
|
||||
column: 25
|
||||
end_location:
|
||||
row: 21
|
||||
column: 33
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B026.py:16:16: B026 Star-arg unpacking after a keyword argument is strongly discouraged
|
||||
|
|
||||
16 | foo("bar", baz="baz", bam="bam")
|
||||
17 | foo(bar="bar", baz="baz", bam="bam")
|
||||
18 | foo(bam="bam", *["bar", "baz"])
|
||||
| ^^^^^^^^^^^^^^^ B026
|
||||
19 | foo(bam="bam", *bar_baz)
|
||||
20 | foo(baz="baz", bam="bam", *["bar"])
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B026.py:17:16: B026 Star-arg unpacking after a keyword argument is strongly discouraged
|
||||
|
|
||||
17 | foo(bar="bar", baz="baz", bam="bam")
|
||||
18 | foo(bam="bam", *["bar", "baz"])
|
||||
19 | foo(bam="bam", *bar_baz)
|
||||
| ^^^^^^^^ B026
|
||||
20 | foo(baz="baz", bam="bam", *["bar"])
|
||||
21 | foo(bar="bar", baz="baz", bam="bam", *[])
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B026.py:18:27: B026 Star-arg unpacking after a keyword argument is strongly discouraged
|
||||
|
|
||||
18 | foo(bam="bam", *["bar", "baz"])
|
||||
19 | foo(bam="bam", *bar_baz)
|
||||
20 | foo(baz="baz", bam="bam", *["bar"])
|
||||
| ^^^^^^^^ B026
|
||||
21 | foo(bar="bar", baz="baz", bam="bam", *[])
|
||||
22 | foo(bam="bam", *["bar"], *["baz"])
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B026.py:19:38: B026 Star-arg unpacking after a keyword argument is strongly discouraged
|
||||
|
|
||||
19 | foo(bam="bam", *bar_baz)
|
||||
20 | foo(baz="baz", bam="bam", *["bar"])
|
||||
21 | foo(bar="bar", baz="baz", bam="bam", *[])
|
||||
| ^^^ B026
|
||||
22 | foo(bam="bam", *["bar"], *["baz"])
|
||||
23 | foo(*["bar"], bam="bam", *["baz"])
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B026.py:20:16: B026 Star-arg unpacking after a keyword argument is strongly discouraged
|
||||
|
|
||||
20 | foo(baz="baz", bam="bam", *["bar"])
|
||||
21 | foo(bar="bar", baz="baz", bam="bam", *[])
|
||||
22 | foo(bam="bam", *["bar"], *["baz"])
|
||||
| ^^^^^^^^ B026
|
||||
23 | foo(*["bar"], bam="bam", *["baz"])
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B026.py:20:26: B026 Star-arg unpacking after a keyword argument is strongly discouraged
|
||||
|
|
||||
20 | foo(baz="baz", bam="bam", *["bar"])
|
||||
21 | foo(bar="bar", baz="baz", bam="bam", *[])
|
||||
22 | foo(bam="bam", *["bar"], *["baz"])
|
||||
| ^^^^^^^^ B026
|
||||
23 | foo(*["bar"], bam="bam", *["baz"])
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B026.py:21:26: B026 Star-arg unpacking after a keyword argument is strongly discouraged
|
||||
|
|
||||
21 | foo(bar="bar", baz="baz", bam="bam", *[])
|
||||
22 | foo(bam="bam", *["bar"], *["baz"])
|
||||
23 | foo(*["bar"], bam="bam", *["baz"])
|
||||
| ^^^^^^^^ B026
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,61 +1,56 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: EmptyMethodWithoutAbstractDecorator
|
||||
body: "`AbstractClass.empty_1` is an empty method in an abstract base class, but has no abstract decorator"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 4
|
||||
end_location:
|
||||
row: 14
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: EmptyMethodWithoutAbstractDecorator
|
||||
body: "`AbstractClass.empty_2` is an empty method in an abstract base class, but has no abstract decorator"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 16
|
||||
column: 4
|
||||
end_location:
|
||||
row: 17
|
||||
column: 12
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: EmptyMethodWithoutAbstractDecorator
|
||||
body: "`AbstractClass.empty_3` is an empty method in an abstract base class, but has no abstract decorator"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 19
|
||||
column: 4
|
||||
end_location:
|
||||
row: 21
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: EmptyMethodWithoutAbstractDecorator
|
||||
body: "`AbstractClass.empty_4` is an empty method in an abstract base class, but has no abstract decorator"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 23
|
||||
column: 4
|
||||
end_location:
|
||||
row: 28
|
||||
column: 12
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B027.py:13:5: B027 `AbstractClass.empty_1` is an empty method in an abstract base class, but has no abstract decorator
|
||||
|
|
||||
13 | class AbstractClass(ABC):
|
||||
14 | def empty_1(self): # error
|
||||
| _____^
|
||||
15 | | ...
|
||||
| |___________^ B027
|
||||
16 |
|
||||
17 | def empty_2(self): # error
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B027.py:16:5: B027 `AbstractClass.empty_2` is an empty method in an abstract base class, but has no abstract decorator
|
||||
|
|
||||
16 | ...
|
||||
17 |
|
||||
18 | def empty_2(self): # error
|
||||
| _____^
|
||||
19 | | pass
|
||||
| |____________^ B027
|
||||
20 |
|
||||
21 | def empty_3(self): # error
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B027.py:19:5: B027 `AbstractClass.empty_3` is an empty method in an abstract base class, but has no abstract decorator
|
||||
|
|
||||
19 | pass
|
||||
20 |
|
||||
21 | def empty_3(self): # error
|
||||
| _____^
|
||||
22 | | """docstring"""
|
||||
23 | | ...
|
||||
| |___________^ B027
|
||||
24 |
|
||||
25 | def empty_4(self): # error
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B027.py:23:5: B027 `AbstractClass.empty_4` is an empty method in an abstract base class, but has no abstract decorator
|
||||
|
|
||||
23 | ...
|
||||
24 |
|
||||
25 | def empty_4(self): # error
|
||||
| _____^
|
||||
26 | | """multiple ellipsis/pass"""
|
||||
27 | | ...
|
||||
28 | | pass
|
||||
29 | | ...
|
||||
30 | | pass
|
||||
| |____________^ B027
|
||||
31 |
|
||||
32 | @notabstract
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
[]
|
||||
|
||||
|
|
|
@ -1,33 +1,23 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: NoExplicitStacklevel
|
||||
body: "No explicit `stacklevel` keyword argument found"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 0
|
||||
end_location:
|
||||
row: 8
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: NoExplicitStacklevel
|
||||
body: "No explicit `stacklevel` keyword argument found"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 9
|
||||
column: 0
|
||||
end_location:
|
||||
row: 9
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B028.py:8:1: B028 No explicit `stacklevel` keyword argument found
|
||||
|
|
||||
8 | """
|
||||
9 |
|
||||
10 | warnings.warn(DeprecationWarning("test"))
|
||||
| ^^^^^^^^^^^^^ B028
|
||||
11 | warnings.warn(DeprecationWarning("test"), source=None)
|
||||
12 | warnings.warn(DeprecationWarning("test"), source=None, stacklevel=2)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B028.py:9:1: B028 No explicit `stacklevel` keyword argument found
|
||||
|
|
||||
9 | warnings.warn(DeprecationWarning("test"))
|
||||
10 | warnings.warn(DeprecationWarning("test"), source=None)
|
||||
| ^^^^^^^^^^^^^ B028
|
||||
11 | warnings.warn(DeprecationWarning("test"), source=None, stacklevel=2)
|
||||
12 | warnings.warn(DeprecationWarning("test"), stacklevel=1)
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,33 +1,24 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: ExceptWithEmptyTuple
|
||||
body: "Using `except ():` with an empty tuple does not catch anything; add exceptions to handle"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 0
|
||||
end_location:
|
||||
row: 9
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ExceptWithEmptyTuple
|
||||
body: "Using `except ():` with an empty tuple does not catch anything; add exceptions to handle"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 0
|
||||
end_location:
|
||||
row: 14
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B029.py:8:1: B029 Using `except ():` with an empty tuple does not catch anything; add exceptions to handle
|
||||
|
|
||||
8 | try:
|
||||
9 | pass
|
||||
10 | / except ():
|
||||
11 | | pass
|
||||
| |________^ B029
|
||||
12 |
|
||||
13 | try:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B029.py:13:1: B029 Using `except ():` with an empty tuple does not catch anything; add exceptions to handle
|
||||
|
|
||||
13 | try:
|
||||
14 | pass
|
||||
15 | / except () as e:
|
||||
16 | | pass
|
||||
| |________^ B029
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,75 +1,49 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: ExceptWithNonExceptionClasses
|
||||
body: "`except` handlers should only be exception classes or tuples of exception classes"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 12
|
||||
column: 7
|
||||
end_location:
|
||||
row: 12
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ExceptWithNonExceptionClasses
|
||||
body: "`except` handlers should only be exception classes or tuples of exception classes"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 17
|
||||
column: 8
|
||||
end_location:
|
||||
row: 17
|
||||
column: 9
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ExceptWithNonExceptionClasses
|
||||
body: "`except` handlers should only be exception classes or tuples of exception classes"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 22
|
||||
column: 20
|
||||
end_location:
|
||||
row: 22
|
||||
column: 57
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ExceptWithNonExceptionClasses
|
||||
body: "`except` handlers should only be exception classes or tuples of exception classes"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 27
|
||||
column: 36
|
||||
end_location:
|
||||
row: 27
|
||||
column: 57
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ExceptWithNonExceptionClasses
|
||||
body: "`except` handlers should only be exception classes or tuples of exception classes"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 33
|
||||
column: 28
|
||||
end_location:
|
||||
row: 33
|
||||
column: 49
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B030.py:12:8: B030 `except` handlers should only be exception classes or tuples of exception classes
|
||||
|
|
||||
12 | try:
|
||||
13 | pass
|
||||
14 | except 1: # error
|
||||
| ^ B030
|
||||
15 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B030.py:17:9: B030 `except` handlers should only be exception classes or tuples of exception classes
|
||||
|
|
||||
17 | try:
|
||||
18 | pass
|
||||
19 | except (1, ValueError): # error
|
||||
| ^ B030
|
||||
20 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B030.py:22:21: B030 `except` handlers should only be exception classes or tuples of exception classes
|
||||
|
|
||||
22 | try:
|
||||
23 | pass
|
||||
24 | except (ValueError, (RuntimeError, (KeyError, TypeError))): # error
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B030
|
||||
25 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B030.py:27:37: B030 `except` handlers should only be exception classes or tuples of exception classes
|
||||
|
|
||||
27 | try:
|
||||
28 | pass
|
||||
29 | except (ValueError, *(RuntimeError, (KeyError, TypeError))): # error
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ B030
|
||||
30 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B030.py:33:29: B030 `except` handlers should only be exception classes or tuples of exception classes
|
||||
|
|
||||
33 | try:
|
||||
34 | pass
|
||||
35 | except (*a, *(RuntimeError, (KeyError, TypeError))): # error
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ B030
|
||||
36 | pass
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,285 +1,198 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 27
|
||||
column: 36
|
||||
end_location:
|
||||
row: 27
|
||||
column: 49
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 29
|
||||
column: 32
|
||||
end_location:
|
||||
row: 29
|
||||
column: 45
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 33
|
||||
column: 30
|
||||
end_location:
|
||||
row: 33
|
||||
column: 43
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 40
|
||||
column: 36
|
||||
end_location:
|
||||
row: 40
|
||||
column: 49
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 46
|
||||
column: 28
|
||||
end_location:
|
||||
row: 46
|
||||
column: 41
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 56
|
||||
column: 16
|
||||
end_location:
|
||||
row: 56
|
||||
column: 29
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 79
|
||||
column: 36
|
||||
end_location:
|
||||
row: 79
|
||||
column: 49
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 82
|
||||
column: 37
|
||||
end_location:
|
||||
row: 82
|
||||
column: 50
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 94
|
||||
column: 64
|
||||
end_location:
|
||||
row: 94
|
||||
column: 77
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 101
|
||||
column: 36
|
||||
end_location:
|
||||
row: 101
|
||||
column: 49
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 108
|
||||
column: 40
|
||||
end_location:
|
||||
row: 108
|
||||
column: 53
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 110
|
||||
column: 40
|
||||
end_location:
|
||||
row: 110
|
||||
column: 53
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 112
|
||||
column: 40
|
||||
end_location:
|
||||
row: 112
|
||||
column: 53
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 113
|
||||
column: 36
|
||||
end_location:
|
||||
row: 113
|
||||
column: 49
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 120
|
||||
column: 48
|
||||
end_location:
|
||||
row: 120
|
||||
column: 61
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 126
|
||||
column: 32
|
||||
end_location:
|
||||
row: 126
|
||||
column: 45
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 135
|
||||
column: 48
|
||||
end_location:
|
||||
row: 135
|
||||
column: 61
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 137
|
||||
column: 48
|
||||
end_location:
|
||||
row: 137
|
||||
column: 61
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 140
|
||||
column: 40
|
||||
end_location:
|
||||
row: 140
|
||||
column: 53
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ReuseOfGroupbyGenerator
|
||||
body: "Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 144
|
||||
column: 32
|
||||
end_location:
|
||||
row: 144
|
||||
column: 45
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:27:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
27 | for shopper in shoppers:
|
||||
28 | shopper = shopper.title()
|
||||
29 | collect_shop_items(shopper, section_items) # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
30 | # We're outside the nested loop and used the group again.
|
||||
31 | collect_shop_items(shopper, section_items) # B031
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:29:33: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
29 | collect_shop_items(shopper, section_items) # B031
|
||||
30 | # We're outside the nested loop and used the group again.
|
||||
31 | collect_shop_items(shopper, section_items) # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
32 |
|
||||
33 | for _section, section_items in groupby(items, key=lambda p: p[1]):
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:33:31: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
33 | for _section, section_items in groupby(items, key=lambda p: p[1]):
|
||||
34 | collect_shop_items("Jane", section_items)
|
||||
35 | collect_shop_items("Joe", section_items) # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:40:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
40 | countdown = 3
|
||||
41 | while countdown > 0:
|
||||
42 | collect_shop_items(shopper, section_items) # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
43 | countdown -= 1
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:46:29: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
46 | collection = []
|
||||
47 | for _section, section_items in groupby(items, key=lambda p: p[1]):
|
||||
48 | collection.append([list(section_items) for _ in range(3)]) # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
49 |
|
||||
50 | unique_items = set()
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:56:17: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
56 | # But it should be detected when used again
|
||||
57 | for item in section_items: # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
58 | another_set.add(item)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:79:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
79 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]):
|
||||
80 | for shopper in shoppers:
|
||||
81 | collect_shop_items(shopper, section_items) # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
82 |
|
||||
83 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]):
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:82:38: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
82 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]):
|
||||
83 | _ = [collect_shop_items(shopper, section_items) for shopper in shoppers] # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
84 |
|
||||
85 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]):
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:94:65: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
94 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]):
|
||||
95 | # The iterator is being used for the second time.
|
||||
96 | _ = [(item1, item2) for item1 in section_items for item2 in section_items] # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
97 |
|
||||
98 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]):
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:101:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
101 | else:
|
||||
102 | collect_shop_items(shopper, section_items)
|
||||
103 | collect_shop_items(shopper, section_items) # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
104 |
|
||||
105 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]):
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:108:41: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
108 | collect_shop_items(shopper, section_items)
|
||||
109 | if _section == "greens":
|
||||
110 | collect_shop_items(shopper, section_items) # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
111 | elif _section == "frozen items":
|
||||
112 | collect_shop_items(shopper, section_items) # B031
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:110:41: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
110 | collect_shop_items(shopper, section_items) # B031
|
||||
111 | elif _section == "frozen items":
|
||||
112 | collect_shop_items(shopper, section_items) # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
113 | else:
|
||||
114 | collect_shop_items(shopper, section_items) # B031
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:112:41: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
112 | collect_shop_items(shopper, section_items) # B031
|
||||
113 | else:
|
||||
114 | collect_shop_items(shopper, section_items) # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
115 | collect_shop_items(shopper, section_items) # B031
|
||||
116 | elif _section == "frozen items":
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:113:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
113 | else:
|
||||
114 | collect_shop_items(shopper, section_items) # B031
|
||||
115 | collect_shop_items(shopper, section_items) # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
116 | elif _section == "frozen items":
|
||||
117 | # Mix `match` and `if` statements
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:120:49: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
120 | collect_shop_items(shopper, section_items)
|
||||
121 | if _section == "fourth":
|
||||
122 | collect_shop_items(shopper, section_items) # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
123 | case _:
|
||||
124 | collect_shop_items(shopper, section_items)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:126:33: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
126 | collect_shop_items(shopper, section_items)
|
||||
127 | # Now, it should detect
|
||||
128 | collect_shop_items(shopper, section_items) # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
129 |
|
||||
130 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]):
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:135:49: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
135 | match shopper:
|
||||
136 | case "Jane":
|
||||
137 | collect_shop_items(shopper, section_items) # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
138 | case _:
|
||||
139 | collect_shop_items(shopper, section_items) # B031
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:137:49: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
137 | collect_shop_items(shopper, section_items) # B031
|
||||
138 | case _:
|
||||
139 | collect_shop_items(shopper, section_items) # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
140 | case "frozen items":
|
||||
141 | collect_shop_items(shopper, section_items)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:140:41: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
140 | case "frozen items":
|
||||
141 | collect_shop_items(shopper, section_items)
|
||||
142 | collect_shop_items(shopper, section_items) # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
143 | case _:
|
||||
144 | collect_shop_items(shopper, section_items)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B031.py:144:33: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
|
||||
|
|
||||
144 | collect_shop_items(shopper, section_items)
|
||||
145 | # Now, it should detect
|
||||
146 | collect_shop_items(shopper, section_items) # B031
|
||||
| ^^^^^^^^^^^^^ B031
|
||||
147 |
|
||||
148 | for group in groupby(items, key=lambda p: p[1]):
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,117 +1,78 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: UnintentionalTypeAnnotation
|
||||
body: "Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)?"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 9
|
||||
column: 0
|
||||
end_location:
|
||||
row: 9
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnintentionalTypeAnnotation
|
||||
body: "Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)?"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 10
|
||||
column: 0
|
||||
end_location:
|
||||
row: 10
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnintentionalTypeAnnotation
|
||||
body: "Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)?"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 12
|
||||
column: 0
|
||||
end_location:
|
||||
row: 12
|
||||
column: 16
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnintentionalTypeAnnotation
|
||||
body: "Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)?"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 0
|
||||
end_location:
|
||||
row: 13
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnintentionalTypeAnnotation
|
||||
body: "Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)?"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 16
|
||||
column: 0
|
||||
end_location:
|
||||
row: 16
|
||||
column: 14
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnintentionalTypeAnnotation
|
||||
body: "Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)?"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 17
|
||||
column: 0
|
||||
end_location:
|
||||
row: 17
|
||||
column: 22
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnintentionalTypeAnnotation
|
||||
body: "Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)?"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 18
|
||||
column: 0
|
||||
end_location:
|
||||
row: 18
|
||||
column: 11
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: UnintentionalTypeAnnotation
|
||||
body: "Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)?"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 19
|
||||
column: 0
|
||||
end_location:
|
||||
row: 19
|
||||
column: 19
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B032.py:9:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)?
|
||||
|
|
||||
9 | dct = {"a": 1}
|
||||
10 |
|
||||
11 | dct["b"]: 2
|
||||
| ^^^^^^^^^^^ B032
|
||||
12 | dct.b: 2
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B032.py:10:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)?
|
||||
|
|
||||
10 | dct["b"]: 2
|
||||
11 | dct.b: 2
|
||||
| ^^^^^^^^ B032
|
||||
12 |
|
||||
13 | dct["b"]: "test"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B032.py:12:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)?
|
||||
|
|
||||
12 | dct.b: 2
|
||||
13 |
|
||||
14 | dct["b"]: "test"
|
||||
| ^^^^^^^^^^^^^^^^ B032
|
||||
15 | dct.b: "test"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B032.py:13:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)?
|
||||
|
|
||||
13 | dct["b"]: "test"
|
||||
14 | dct.b: "test"
|
||||
| ^^^^^^^^^^^^^ B032
|
||||
15 |
|
||||
16 | test = "test"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B032.py:16:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)?
|
||||
|
|
||||
16 | test = "test"
|
||||
17 | dct["b"]: test
|
||||
| ^^^^^^^^^^^^^^ B032
|
||||
18 | dct["b"]: test.lower()
|
||||
19 | dct.b: test
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B032.py:17:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)?
|
||||
|
|
||||
17 | test = "test"
|
||||
18 | dct["b"]: test
|
||||
19 | dct["b"]: test.lower()
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ B032
|
||||
20 | dct.b: test
|
||||
21 | dct.b: test.lower()
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B032.py:18:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)?
|
||||
|
|
||||
18 | dct["b"]: test
|
||||
19 | dct["b"]: test.lower()
|
||||
20 | dct.b: test
|
||||
| ^^^^^^^^^^^ B032
|
||||
21 | dct.b: test.lower()
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B032.py:19:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)?
|
||||
|
|
||||
19 | dct["b"]: test.lower()
|
||||
20 | dct.b: test
|
||||
21 | dct.b: test.lower()
|
||||
| ^^^^^^^^^^^^^^^^^^^ B032
|
||||
22 |
|
||||
23 | # Do not flag below
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,89 +1,60 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: RaiseWithoutFromInsideExcept
|
||||
body: "Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 10
|
||||
column: 8
|
||||
end_location:
|
||||
row: 10
|
||||
column: 23
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RaiseWithoutFromInsideExcept
|
||||
body: "Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 11
|
||||
column: 4
|
||||
end_location:
|
||||
row: 11
|
||||
column: 21
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RaiseWithoutFromInsideExcept
|
||||
body: "Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 16
|
||||
column: 4
|
||||
end_location:
|
||||
row: 16
|
||||
column: 39
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RaiseWithoutFromInsideExcept
|
||||
body: "Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 62
|
||||
column: 8
|
||||
end_location:
|
||||
row: 62
|
||||
column: 35
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RaiseWithoutFromInsideExcept
|
||||
body: "Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 64
|
||||
column: 8
|
||||
end_location:
|
||||
row: 64
|
||||
column: 35
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: RaiseWithoutFromInsideExcept
|
||||
body: "Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 72
|
||||
column: 12
|
||||
end_location:
|
||||
row: 72
|
||||
column: 39
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B904.py:10:9: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
|
||||
|
|
||||
10 | except ValueError:
|
||||
11 | if "abc":
|
||||
12 | raise TypeError
|
||||
| ^^^^^^^^^^^^^^^ B904
|
||||
13 | raise UserWarning
|
||||
14 | except AssertionError:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B904.py:11:5: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
|
||||
|
|
||||
11 | if "abc":
|
||||
12 | raise TypeError
|
||||
13 | raise UserWarning
|
||||
| ^^^^^^^^^^^^^^^^^ B904
|
||||
14 | except AssertionError:
|
||||
15 | raise # Bare `raise` should not be an error
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B904.py:16:5: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
|
||||
|
|
||||
16 | except Exception as err:
|
||||
17 | assert err
|
||||
18 | raise Exception("No cause here...")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904
|
||||
19 | except BaseException as base_err:
|
||||
20 | # Might use this instead of bare raise with the `.with_traceback()` method
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B904.py:62:9: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
|
||||
|
|
||||
62 | except Exception as e:
|
||||
63 | if ...:
|
||||
64 | raise RuntimeError("boom!")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904
|
||||
65 | else:
|
||||
66 | raise RuntimeError("bang!")
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B904.py:64:9: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
|
||||
|
|
||||
64 | raise RuntimeError("boom!")
|
||||
65 | else:
|
||||
66 | raise RuntimeError("bang!")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B904.py:72:13: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
|
||||
|
|
||||
72 | match 0:
|
||||
73 | case 0:
|
||||
74 | raise RuntimeError("boom!")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,103 +1,70 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: ZipWithoutExplicitStrict
|
||||
body: "`zip()` without an explicit `strict=` parameter"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 1
|
||||
column: 0
|
||||
end_location:
|
||||
row: 1
|
||||
column: 5
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ZipWithoutExplicitStrict
|
||||
body: "`zip()` without an explicit `strict=` parameter"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 2
|
||||
column: 0
|
||||
end_location:
|
||||
row: 2
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ZipWithoutExplicitStrict
|
||||
body: "`zip()` without an explicit `strict=` parameter"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 3
|
||||
column: 0
|
||||
end_location:
|
||||
row: 3
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ZipWithoutExplicitStrict
|
||||
body: "`zip()` without an explicit `strict=` parameter"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 0
|
||||
end_location:
|
||||
row: 4
|
||||
column: 24
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ZipWithoutExplicitStrict
|
||||
body: "`zip()` without an explicit `strict=` parameter"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 15
|
||||
end_location:
|
||||
row: 4
|
||||
column: 23
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ZipWithoutExplicitStrict
|
||||
body: "`zip()` without an explicit `strict=` parameter"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 4
|
||||
end_location:
|
||||
row: 5
|
||||
column: 12
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: ZipWithoutExplicitStrict
|
||||
body: "`zip()` without an explicit `strict=` parameter"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 6
|
||||
column: 0
|
||||
end_location:
|
||||
row: 6
|
||||
column: 26
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B905.py:1:1: B905 `zip()` without an explicit `strict=` parameter
|
||||
|
|
||||
1 | zip()
|
||||
| ^^^^^ B905
|
||||
2 | zip(range(3))
|
||||
3 | zip("a", "b")
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B905.py:2:1: B905 `zip()` without an explicit `strict=` parameter
|
||||
|
|
||||
2 | zip()
|
||||
3 | zip(range(3))
|
||||
| ^^^^^^^^^^^^^ B905
|
||||
4 | zip("a", "b")
|
||||
5 | zip("a", "b", *zip("c"))
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B905.py:3:1: B905 `zip()` without an explicit `strict=` parameter
|
||||
|
|
||||
3 | zip()
|
||||
4 | zip(range(3))
|
||||
5 | zip("a", "b")
|
||||
| ^^^^^^^^^^^^^ B905
|
||||
6 | zip("a", "b", *zip("c"))
|
||||
7 | zip(zip("a"), strict=False)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B905.py:4:1: B905 `zip()` without an explicit `strict=` parameter
|
||||
|
|
||||
4 | zip(range(3))
|
||||
5 | zip("a", "b")
|
||||
6 | zip("a", "b", *zip("c"))
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ B905
|
||||
7 | zip(zip("a"), strict=False)
|
||||
8 | zip(zip("a", strict=True))
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B905.py:4:16: B905 `zip()` without an explicit `strict=` parameter
|
||||
|
|
||||
4 | zip(range(3))
|
||||
5 | zip("a", "b")
|
||||
6 | zip("a", "b", *zip("c"))
|
||||
| ^^^^^^^^ B905
|
||||
7 | zip(zip("a"), strict=False)
|
||||
8 | zip(zip("a", strict=True))
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B905.py:5:5: B905 `zip()` without an explicit `strict=` parameter
|
||||
|
|
||||
5 | zip("a", "b")
|
||||
6 | zip("a", "b", *zip("c"))
|
||||
7 | zip(zip("a"), strict=False)
|
||||
| ^^^^^^^^ B905
|
||||
8 | zip(zip("a", strict=True))
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_bugbear/B905.py:6:1: B905 `zip()` without an explicit `strict=` parameter
|
||||
|
|
||||
6 | zip("a", "b", *zip("c"))
|
||||
7 | zip(zip("a"), strict=False)
|
||||
8 | zip(zip("a", strict=True))
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ B905
|
||||
9 |
|
||||
10 | zip(range(3), strict=True)
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,19 +1,11 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: FunctionCallInDefaultArgument
|
||||
body: "Do not perform function call `Depends` in argument defaults"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 19
|
||||
column: 50
|
||||
end_location:
|
||||
row: 19
|
||||
column: 63
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_bugbear/B008_extended.py:19:51: B008 Do not perform function call `Depends` in argument defaults
|
||||
|
|
||||
19 | def error_due_to_missing_import(data: List[str] = Depends(None)):
|
||||
| ^^^^^^^^^^^^^ B008
|
||||
20 | ...
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -7,8 +7,9 @@ pub(crate) mod types;
|
|||
mod tests {
|
||||
use std::path::Path;
|
||||
|
||||
use crate::assert_messages;
|
||||
use anyhow::Result;
|
||||
use insta::assert_yaml_snapshot;
|
||||
|
||||
use test_case::test_case;
|
||||
|
||||
use crate::registry::Rule;
|
||||
|
@ -24,7 +25,7 @@ mod tests {
|
|||
Path::new("flake8_builtins").join(path).as_path(),
|
||||
&Settings::for_rule(rule_code),
|
||||
)?;
|
||||
assert_yaml_snapshot!(snapshot, diagnostics);
|
||||
assert_messages!(snapshot, diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -48,7 +49,7 @@ mod tests {
|
|||
},
|
||||
)?;
|
||||
|
||||
assert_yaml_snapshot!(snapshot, diagnostics);
|
||||
assert_messages!(snapshot, diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,285 +1,193 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_builtins/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `sum` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 1
|
||||
column: 0
|
||||
end_location:
|
||||
row: 1
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `int` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 2
|
||||
column: 0
|
||||
end_location:
|
||||
row: 2
|
||||
column: 29
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `dir` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 3
|
||||
column: 0
|
||||
end_location:
|
||||
row: 3
|
||||
column: 32
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `print` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 0
|
||||
end_location:
|
||||
row: 5
|
||||
column: 5
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `copyright` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 6
|
||||
column: 0
|
||||
end_location:
|
||||
row: 6
|
||||
column: 9
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `complex` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 7
|
||||
column: 1
|
||||
end_location:
|
||||
row: 7
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `float` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 0
|
||||
end_location:
|
||||
row: 8
|
||||
column: 5
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `object` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 8
|
||||
end_location:
|
||||
row: 8
|
||||
column: 14
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `min` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 9
|
||||
column: 0
|
||||
end_location:
|
||||
row: 9
|
||||
column: 3
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `max` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 9
|
||||
column: 5
|
||||
end_location:
|
||||
row: 9
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `id` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 11
|
||||
column: 0
|
||||
end_location:
|
||||
row: 11
|
||||
column: 2
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `bytes` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 0
|
||||
end_location:
|
||||
row: 14
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `slice` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 16
|
||||
column: 0
|
||||
end_location:
|
||||
row: 17
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `ValueError` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 21
|
||||
column: 0
|
||||
end_location:
|
||||
row: 22
|
||||
column: 7
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `memoryview` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 24
|
||||
column: 4
|
||||
end_location:
|
||||
row: 24
|
||||
column: 14
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `bytearray` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 24
|
||||
column: 17
|
||||
end_location:
|
||||
row: 24
|
||||
column: 26
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `str` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 27
|
||||
column: 21
|
||||
end_location:
|
||||
row: 27
|
||||
column: 24
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `all` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 27
|
||||
column: 44
|
||||
end_location:
|
||||
row: 27
|
||||
column: 47
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `any` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 27
|
||||
column: 49
|
||||
end_location:
|
||||
row: 27
|
||||
column: 52
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `sum` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 30
|
||||
column: 7
|
||||
end_location:
|
||||
row: 30
|
||||
column: 10
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:1:1: A001 Variable `sum` is shadowing a python builtin
|
||||
|
|
||||
1 | import some as sum
|
||||
| ^^^^^^^^^^^^^^^^^^ A001
|
||||
2 | from some import other as int
|
||||
3 | from directory import new as dir
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:2:1: A001 Variable `int` is shadowing a python builtin
|
||||
|
|
||||
2 | import some as sum
|
||||
3 | from some import other as int
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ A001
|
||||
4 | from directory import new as dir
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:3:1: A001 Variable `dir` is shadowing a python builtin
|
||||
|
|
||||
3 | import some as sum
|
||||
4 | from some import other as int
|
||||
5 | from directory import new as dir
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ A001
|
||||
6 |
|
||||
7 | print = 1
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:5:1: A001 Variable `print` is shadowing a python builtin
|
||||
|
|
||||
5 | from directory import new as dir
|
||||
6 |
|
||||
7 | print = 1
|
||||
| ^^^^^ A001
|
||||
8 | copyright: 'annotation' = 2
|
||||
9 | (complex := 3)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:6:1: A001 Variable `copyright` is shadowing a python builtin
|
||||
|
|
||||
6 | print = 1
|
||||
7 | copyright: 'annotation' = 2
|
||||
| ^^^^^^^^^ A001
|
||||
8 | (complex := 3)
|
||||
9 | float = object = 4
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:7:2: A001 Variable `complex` is shadowing a python builtin
|
||||
|
|
||||
7 | print = 1
|
||||
8 | copyright: 'annotation' = 2
|
||||
9 | (complex := 3)
|
||||
| ^^^^^^^ A001
|
||||
10 | float = object = 4
|
||||
11 | min, max = 5, 6
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:8:1: A001 Variable `float` is shadowing a python builtin
|
||||
|
|
||||
8 | copyright: 'annotation' = 2
|
||||
9 | (complex := 3)
|
||||
10 | float = object = 4
|
||||
| ^^^^^ A001
|
||||
11 | min, max = 5, 6
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:8:9: A001 Variable `object` is shadowing a python builtin
|
||||
|
|
||||
8 | copyright: 'annotation' = 2
|
||||
9 | (complex := 3)
|
||||
10 | float = object = 4
|
||||
| ^^^^^^ A001
|
||||
11 | min, max = 5, 6
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:9:1: A001 Variable `min` is shadowing a python builtin
|
||||
|
|
||||
9 | (complex := 3)
|
||||
10 | float = object = 4
|
||||
11 | min, max = 5, 6
|
||||
| ^^^ A001
|
||||
12 |
|
||||
13 | id = 4
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:9:6: A001 Variable `max` is shadowing a python builtin
|
||||
|
|
||||
9 | (complex := 3)
|
||||
10 | float = object = 4
|
||||
11 | min, max = 5, 6
|
||||
| ^^^ A001
|
||||
12 |
|
||||
13 | id = 4
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:11:1: A001 Variable `id` is shadowing a python builtin
|
||||
|
|
||||
11 | min, max = 5, 6
|
||||
12 |
|
||||
13 | id = 4
|
||||
| ^^ A001
|
||||
14 |
|
||||
15 | def bytes():
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:13:1: A001 Variable `bytes` is shadowing a python builtin
|
||||
|
|
||||
13 | id = 4
|
||||
14 |
|
||||
15 | / def bytes():
|
||||
16 | | pass
|
||||
| |________^ A001
|
||||
17 |
|
||||
18 | class slice:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:16:1: A001 Variable `slice` is shadowing a python builtin
|
||||
|
|
||||
16 | pass
|
||||
17 |
|
||||
18 | / class slice:
|
||||
19 | | pass
|
||||
| |________^ A001
|
||||
20 |
|
||||
21 | try:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:21:1: A001 Variable `ValueError` is shadowing a python builtin
|
||||
|
|
||||
21 | try:
|
||||
22 | ...
|
||||
23 | / except ImportError as ValueError:
|
||||
24 | | ...
|
||||
| |_______^ A001
|
||||
25 |
|
||||
26 | for memoryview, *bytearray in []:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:24:5: A001 Variable `memoryview` is shadowing a python builtin
|
||||
|
|
||||
24 | ...
|
||||
25 |
|
||||
26 | for memoryview, *bytearray in []:
|
||||
| ^^^^^^^^^^ A001
|
||||
27 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:24:18: A001 Variable `bytearray` is shadowing a python builtin
|
||||
|
|
||||
24 | ...
|
||||
25 |
|
||||
26 | for memoryview, *bytearray in []:
|
||||
| ^^^^^^^^^ A001
|
||||
27 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:27:22: A001 Variable `str` is shadowing a python builtin
|
||||
|
|
||||
27 | pass
|
||||
28 |
|
||||
29 | with open('file') as str, open('file2') as (all, any):
|
||||
| ^^^ A001
|
||||
30 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:27:45: A001 Variable `all` is shadowing a python builtin
|
||||
|
|
||||
27 | pass
|
||||
28 |
|
||||
29 | with open('file') as str, open('file2') as (all, any):
|
||||
| ^^^ A001
|
||||
30 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:27:50: A001 Variable `any` is shadowing a python builtin
|
||||
|
|
||||
27 | pass
|
||||
28 |
|
||||
29 | with open('file') as str, open('file2') as (all, any):
|
||||
| ^^^ A001
|
||||
30 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:30:8: A001 Variable `sum` is shadowing a python builtin
|
||||
|
|
||||
30 | pass
|
||||
31 |
|
||||
32 | [0 for sum in ()]
|
||||
| ^^^ A001
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,257 +1,173 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_builtins/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `sum` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 1
|
||||
column: 0
|
||||
end_location:
|
||||
row: 1
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `int` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 2
|
||||
column: 0
|
||||
end_location:
|
||||
row: 2
|
||||
column: 29
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `print` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 0
|
||||
end_location:
|
||||
row: 5
|
||||
column: 5
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `copyright` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 6
|
||||
column: 0
|
||||
end_location:
|
||||
row: 6
|
||||
column: 9
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `complex` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 7
|
||||
column: 1
|
||||
end_location:
|
||||
row: 7
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `float` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 0
|
||||
end_location:
|
||||
row: 8
|
||||
column: 5
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `object` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 8
|
||||
end_location:
|
||||
row: 8
|
||||
column: 14
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `min` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 9
|
||||
column: 0
|
||||
end_location:
|
||||
row: 9
|
||||
column: 3
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `max` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 9
|
||||
column: 5
|
||||
end_location:
|
||||
row: 9
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `bytes` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 13
|
||||
column: 0
|
||||
end_location:
|
||||
row: 14
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `slice` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 16
|
||||
column: 0
|
||||
end_location:
|
||||
row: 17
|
||||
column: 8
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `ValueError` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 21
|
||||
column: 0
|
||||
end_location:
|
||||
row: 22
|
||||
column: 7
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `memoryview` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 24
|
||||
column: 4
|
||||
end_location:
|
||||
row: 24
|
||||
column: 14
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `bytearray` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 24
|
||||
column: 17
|
||||
end_location:
|
||||
row: 24
|
||||
column: 26
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `str` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 27
|
||||
column: 21
|
||||
end_location:
|
||||
row: 27
|
||||
column: 24
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `all` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 27
|
||||
column: 44
|
||||
end_location:
|
||||
row: 27
|
||||
column: 47
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `any` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 27
|
||||
column: 49
|
||||
end_location:
|
||||
row: 27
|
||||
column: 52
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinVariableShadowing
|
||||
body: "Variable `sum` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 30
|
||||
column: 7
|
||||
end_location:
|
||||
row: 30
|
||||
column: 10
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:1:1: A001 Variable `sum` is shadowing a python builtin
|
||||
|
|
||||
1 | import some as sum
|
||||
| ^^^^^^^^^^^^^^^^^^ A001
|
||||
2 | from some import other as int
|
||||
3 | from directory import new as dir
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:2:1: A001 Variable `int` is shadowing a python builtin
|
||||
|
|
||||
2 | import some as sum
|
||||
3 | from some import other as int
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ A001
|
||||
4 | from directory import new as dir
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:5:1: A001 Variable `print` is shadowing a python builtin
|
||||
|
|
||||
5 | from directory import new as dir
|
||||
6 |
|
||||
7 | print = 1
|
||||
| ^^^^^ A001
|
||||
8 | copyright: 'annotation' = 2
|
||||
9 | (complex := 3)
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:6:1: A001 Variable `copyright` is shadowing a python builtin
|
||||
|
|
||||
6 | print = 1
|
||||
7 | copyright: 'annotation' = 2
|
||||
| ^^^^^^^^^ A001
|
||||
8 | (complex := 3)
|
||||
9 | float = object = 4
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:7:2: A001 Variable `complex` is shadowing a python builtin
|
||||
|
|
||||
7 | print = 1
|
||||
8 | copyright: 'annotation' = 2
|
||||
9 | (complex := 3)
|
||||
| ^^^^^^^ A001
|
||||
10 | float = object = 4
|
||||
11 | min, max = 5, 6
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:8:1: A001 Variable `float` is shadowing a python builtin
|
||||
|
|
||||
8 | copyright: 'annotation' = 2
|
||||
9 | (complex := 3)
|
||||
10 | float = object = 4
|
||||
| ^^^^^ A001
|
||||
11 | min, max = 5, 6
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:8:9: A001 Variable `object` is shadowing a python builtin
|
||||
|
|
||||
8 | copyright: 'annotation' = 2
|
||||
9 | (complex := 3)
|
||||
10 | float = object = 4
|
||||
| ^^^^^^ A001
|
||||
11 | min, max = 5, 6
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:9:1: A001 Variable `min` is shadowing a python builtin
|
||||
|
|
||||
9 | (complex := 3)
|
||||
10 | float = object = 4
|
||||
11 | min, max = 5, 6
|
||||
| ^^^ A001
|
||||
12 |
|
||||
13 | id = 4
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:9:6: A001 Variable `max` is shadowing a python builtin
|
||||
|
|
||||
9 | (complex := 3)
|
||||
10 | float = object = 4
|
||||
11 | min, max = 5, 6
|
||||
| ^^^ A001
|
||||
12 |
|
||||
13 | id = 4
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:13:1: A001 Variable `bytes` is shadowing a python builtin
|
||||
|
|
||||
13 | id = 4
|
||||
14 |
|
||||
15 | / def bytes():
|
||||
16 | | pass
|
||||
| |________^ A001
|
||||
17 |
|
||||
18 | class slice:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:16:1: A001 Variable `slice` is shadowing a python builtin
|
||||
|
|
||||
16 | pass
|
||||
17 |
|
||||
18 | / class slice:
|
||||
19 | | pass
|
||||
| |________^ A001
|
||||
20 |
|
||||
21 | try:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:21:1: A001 Variable `ValueError` is shadowing a python builtin
|
||||
|
|
||||
21 | try:
|
||||
22 | ...
|
||||
23 | / except ImportError as ValueError:
|
||||
24 | | ...
|
||||
| |_______^ A001
|
||||
25 |
|
||||
26 | for memoryview, *bytearray in []:
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:24:5: A001 Variable `memoryview` is shadowing a python builtin
|
||||
|
|
||||
24 | ...
|
||||
25 |
|
||||
26 | for memoryview, *bytearray in []:
|
||||
| ^^^^^^^^^^ A001
|
||||
27 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:24:18: A001 Variable `bytearray` is shadowing a python builtin
|
||||
|
|
||||
24 | ...
|
||||
25 |
|
||||
26 | for memoryview, *bytearray in []:
|
||||
| ^^^^^^^^^ A001
|
||||
27 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:27:22: A001 Variable `str` is shadowing a python builtin
|
||||
|
|
||||
27 | pass
|
||||
28 |
|
||||
29 | with open('file') as str, open('file2') as (all, any):
|
||||
| ^^^ A001
|
||||
30 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:27:45: A001 Variable `all` is shadowing a python builtin
|
||||
|
|
||||
27 | pass
|
||||
28 |
|
||||
29 | with open('file') as str, open('file2') as (all, any):
|
||||
| ^^^ A001
|
||||
30 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:27:50: A001 Variable `any` is shadowing a python builtin
|
||||
|
|
||||
27 | pass
|
||||
28 |
|
||||
29 | with open('file') as str, open('file2') as (all, any):
|
||||
| ^^^ A001
|
||||
30 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A001.py:30:8: A001 Variable `sum` is shadowing a python builtin
|
||||
|
|
||||
30 | pass
|
||||
31 |
|
||||
32 | [0 for sum in ()]
|
||||
| ^^^ A001
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,131 +1,72 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_builtins/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: BuiltinArgumentShadowing
|
||||
body: "Argument `str` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 1
|
||||
column: 10
|
||||
end_location:
|
||||
row: 1
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinArgumentShadowing
|
||||
body: "Argument `type` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 1
|
||||
column: 18
|
||||
end_location:
|
||||
row: 1
|
||||
column: 22
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinArgumentShadowing
|
||||
body: "Argument `complex` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 1
|
||||
column: 25
|
||||
end_location:
|
||||
row: 1
|
||||
column: 32
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinArgumentShadowing
|
||||
body: "Argument `Exception` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 1
|
||||
column: 34
|
||||
end_location:
|
||||
row: 1
|
||||
column: 43
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinArgumentShadowing
|
||||
body: "Argument `getattr` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 1
|
||||
column: 47
|
||||
end_location:
|
||||
row: 1
|
||||
column: 54
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinArgumentShadowing
|
||||
body: "Argument `bytes` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 16
|
||||
end_location:
|
||||
row: 5
|
||||
column: 21
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinArgumentShadowing
|
||||
body: "Argument `id` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 16
|
||||
end_location:
|
||||
row: 8
|
||||
column: 18
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinArgumentShadowing
|
||||
body: "Argument `dir` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 8
|
||||
column: 20
|
||||
end_location:
|
||||
row: 8
|
||||
column: 23
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinArgumentShadowing
|
||||
body: "Argument `float` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 11
|
||||
column: 15
|
||||
end_location:
|
||||
row: 11
|
||||
column: 20
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_builtins/A002.py:1:11: A002 Argument `str` is shadowing a python builtin
|
||||
|
|
||||
1 | def func1(str, /, type, *complex, Exception, **getattr):
|
||||
| ^^^ A002
|
||||
2 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A002.py:1:19: A002 Argument `type` is shadowing a python builtin
|
||||
|
|
||||
1 | def func1(str, /, type, *complex, Exception, **getattr):
|
||||
| ^^^^ A002
|
||||
2 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A002.py:1:26: A002 Argument `complex` is shadowing a python builtin
|
||||
|
|
||||
1 | def func1(str, /, type, *complex, Exception, **getattr):
|
||||
| ^^^^^^^ A002
|
||||
2 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A002.py:1:35: A002 Argument `Exception` is shadowing a python builtin
|
||||
|
|
||||
1 | def func1(str, /, type, *complex, Exception, **getattr):
|
||||
| ^^^^^^^^^ A002
|
||||
2 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A002.py:1:48: A002 Argument `getattr` is shadowing a python builtin
|
||||
|
|
||||
1 | def func1(str, /, type, *complex, Exception, **getattr):
|
||||
| ^^^^^^^ A002
|
||||
2 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A002.py:5:17: A002 Argument `bytes` is shadowing a python builtin
|
||||
|
|
||||
5 | async def func2(bytes):
|
||||
| ^^^^^ A002
|
||||
6 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A002.py:8:17: A002 Argument `id` is shadowing a python builtin
|
||||
|
|
||||
8 | pass
|
||||
9 |
|
||||
10 | async def func3(id, dir):
|
||||
| ^^ A002
|
||||
11 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A002.py:8:21: A002 Argument `dir` is shadowing a python builtin
|
||||
|
|
||||
8 | pass
|
||||
9 |
|
||||
10 | async def func3(id, dir):
|
||||
| ^^^ A002
|
||||
11 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A002.py:11:16: A002 Argument `float` is shadowing a python builtin
|
||||
|
|
||||
11 | pass
|
||||
12 |
|
||||
13 | map([], lambda float: ...)
|
||||
| ^^^^^ A002
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,103 +1,54 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_builtins/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: BuiltinArgumentShadowing
|
||||
body: "Argument `str` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 1
|
||||
column: 10
|
||||
end_location:
|
||||
row: 1
|
||||
column: 13
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinArgumentShadowing
|
||||
body: "Argument `type` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 1
|
||||
column: 18
|
||||
end_location:
|
||||
row: 1
|
||||
column: 22
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinArgumentShadowing
|
||||
body: "Argument `complex` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 1
|
||||
column: 25
|
||||
end_location:
|
||||
row: 1
|
||||
column: 32
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinArgumentShadowing
|
||||
body: "Argument `Exception` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 1
|
||||
column: 34
|
||||
end_location:
|
||||
row: 1
|
||||
column: 43
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinArgumentShadowing
|
||||
body: "Argument `getattr` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 1
|
||||
column: 47
|
||||
end_location:
|
||||
row: 1
|
||||
column: 54
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinArgumentShadowing
|
||||
body: "Argument `bytes` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 5
|
||||
column: 16
|
||||
end_location:
|
||||
row: 5
|
||||
column: 21
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinArgumentShadowing
|
||||
body: "Argument `float` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 11
|
||||
column: 15
|
||||
end_location:
|
||||
row: 11
|
||||
column: 20
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_builtins/A002.py:1:11: A002 Argument `str` is shadowing a python builtin
|
||||
|
|
||||
1 | def func1(str, /, type, *complex, Exception, **getattr):
|
||||
| ^^^ A002
|
||||
2 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A002.py:1:19: A002 Argument `type` is shadowing a python builtin
|
||||
|
|
||||
1 | def func1(str, /, type, *complex, Exception, **getattr):
|
||||
| ^^^^ A002
|
||||
2 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A002.py:1:26: A002 Argument `complex` is shadowing a python builtin
|
||||
|
|
||||
1 | def func1(str, /, type, *complex, Exception, **getattr):
|
||||
| ^^^^^^^ A002
|
||||
2 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A002.py:1:35: A002 Argument `Exception` is shadowing a python builtin
|
||||
|
|
||||
1 | def func1(str, /, type, *complex, Exception, **getattr):
|
||||
| ^^^^^^^^^ A002
|
||||
2 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A002.py:1:48: A002 Argument `getattr` is shadowing a python builtin
|
||||
|
|
||||
1 | def func1(str, /, type, *complex, Exception, **getattr):
|
||||
| ^^^^^^^ A002
|
||||
2 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A002.py:5:17: A002 Argument `bytes` is shadowing a python builtin
|
||||
|
|
||||
5 | async def func2(bytes):
|
||||
| ^^^^^ A002
|
||||
6 | pass
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A002.py:11:16: A002 Argument `float` is shadowing a python builtin
|
||||
|
|
||||
11 | pass
|
||||
12 |
|
||||
13 | map([], lambda float: ...)
|
||||
| ^^^^^ A002
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -1,61 +1,42 @@
|
|||
---
|
||||
source: crates/ruff/src/rules/flake8_builtins/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
name: BuiltinAttributeShadowing
|
||||
body: "Class attribute `ImportError` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 2
|
||||
column: 4
|
||||
end_location:
|
||||
row: 2
|
||||
column: 15
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinAttributeShadowing
|
||||
body: "Class attribute `id` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 3
|
||||
column: 4
|
||||
end_location:
|
||||
row: 3
|
||||
column: 6
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinAttributeShadowing
|
||||
body: "Class attribute `dir` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 4
|
||||
column: 4
|
||||
end_location:
|
||||
row: 4
|
||||
column: 7
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
- kind:
|
||||
name: BuiltinAttributeShadowing
|
||||
body: "Class attribute `str` is shadowing a python builtin"
|
||||
suggestion: ~
|
||||
fixable: false
|
||||
location:
|
||||
row: 11
|
||||
column: 4
|
||||
end_location:
|
||||
row: 12
|
||||
column: 12
|
||||
fix:
|
||||
edits: []
|
||||
parent: ~
|
||||
./resources/test/fixtures/flake8_builtins/A003.py:2:5: A003 Class attribute `ImportError` is shadowing a python builtin
|
||||
|
|
||||
2 | class MyClass:
|
||||
3 | ImportError = 4
|
||||
| ^^^^^^^^^^^ A003
|
||||
4 | id = 5
|
||||
5 | dir = "/"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A003.py:3:5: A003 Class attribute `id` is shadowing a python builtin
|
||||
|
|
||||
3 | class MyClass:
|
||||
4 | ImportError = 4
|
||||
5 | id = 5
|
||||
| ^^ A003
|
||||
6 | dir = "/"
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A003.py:4:5: A003 Class attribute `dir` is shadowing a python builtin
|
||||
|
|
||||
4 | ImportError = 4
|
||||
5 | id = 5
|
||||
6 | dir = "/"
|
||||
| ^^^ A003
|
||||
7 |
|
||||
8 | def __init__(self):
|
||||
|
|
||||
|
||||
./resources/test/fixtures/flake8_builtins/A003.py:11:5: A003 Class attribute `str` is shadowing a python builtin
|
||||
|
|
||||
11 | self.dir = "."
|
||||
12 |
|
||||
13 | def str(self):
|
||||
| _____^
|
||||
14 | | pass
|
||||
| |____________^ A003
|
||||
|
|
||||
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue