mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:47 +00:00
Add function name to B008 message
This commit is contained in:
parent
695b06ba60
commit
9ec7e6bcd6
5 changed files with 43 additions and 23 deletions
|
@ -515,7 +515,7 @@ For more, see [flake8-bugbear](https://pypi.org/project/flake8-bugbear/22.10.27/
|
|||
| B005 | StripWithMultiCharacters | Using `.strip()` with multi-character strings is misleading the reader. | |
|
||||
| B006 | MutableArgumentDefault | Do not use mutable data structures for argument defaults. | |
|
||||
| B007 | UnusedLoopControlVariable | Loop control variable `i` not used within the loop body. | 🛠 |
|
||||
| B008 | FunctionCallArgumentDefault | Do not perform function calls in argument defaults. | |
|
||||
| B008 | FunctionCallArgumentDefault | Do not perform function call in argument defaults | |
|
||||
| B009 | GetAttrWithConstant | Do not call `getattr` with a constant attribute value, it is not any safer than normal property access. | 🛠 |
|
||||
| B010 | SetAttrWithConstant | Do not call `setattr` with a constant attribute value, it is not any safer than normal property access. | |
|
||||
| B011 | DoNotAssertFalse | Do not `assert False` (`python -O` removes these calls), raise `AssertionError()` | 🛠 |
|
||||
|
|
|
@ -382,7 +382,7 @@ pub enum CheckKind {
|
|||
StripWithMultiCharacters,
|
||||
MutableArgumentDefault,
|
||||
UnusedLoopControlVariable(String),
|
||||
FunctionCallArgumentDefault,
|
||||
FunctionCallArgumentDefault(Option<String>),
|
||||
GetAttrWithConstant,
|
||||
SetAttrWithConstant,
|
||||
DoNotAssertFalse,
|
||||
|
@ -619,7 +619,7 @@ impl CheckCode {
|
|||
CheckCode::B005 => CheckKind::StripWithMultiCharacters,
|
||||
CheckCode::B006 => CheckKind::MutableArgumentDefault,
|
||||
CheckCode::B007 => CheckKind::UnusedLoopControlVariable("i".to_string()),
|
||||
CheckCode::B008 => CheckKind::FunctionCallArgumentDefault,
|
||||
CheckCode::B008 => CheckKind::FunctionCallArgumentDefault(None),
|
||||
CheckCode::B009 => CheckKind::GetAttrWithConstant,
|
||||
CheckCode::B010 => CheckKind::SetAttrWithConstant,
|
||||
CheckCode::B011 => CheckKind::DoNotAssertFalse,
|
||||
|
@ -1064,7 +1064,7 @@ impl CheckKind {
|
|||
CheckKind::StripWithMultiCharacters => &CheckCode::B005,
|
||||
CheckKind::MutableArgumentDefault => &CheckCode::B006,
|
||||
CheckKind::UnusedLoopControlVariable(_) => &CheckCode::B007,
|
||||
CheckKind::FunctionCallArgumentDefault => &CheckCode::B008,
|
||||
CheckKind::FunctionCallArgumentDefault(_) => &CheckCode::B008,
|
||||
CheckKind::GetAttrWithConstant => &CheckCode::B009,
|
||||
CheckKind::SetAttrWithConstant => &CheckCode::B010,
|
||||
CheckKind::DoNotAssertFalse => &CheckCode::B011,
|
||||
|
@ -1389,8 +1389,12 @@ impl CheckKind {
|
|||
"Loop control variable `{name}` not used within the loop body. If this is \
|
||||
intended, start the name with an underscore."
|
||||
),
|
||||
CheckKind::FunctionCallArgumentDefault => {
|
||||
"Do not perform function calls in argument defaults.".to_string()
|
||||
CheckKind::FunctionCallArgumentDefault(name) => {
|
||||
if let Some(name) = name {
|
||||
format!("Do not perform function call `{name}` in argument defaults")
|
||||
} else {
|
||||
"Do not perform function call in argument defaults".to_string()
|
||||
}
|
||||
}
|
||||
CheckKind::GetAttrWithConstant => "Do not call `getattr` with a constant attribute \
|
||||
value, it is not any safer than normal property \
|
||||
|
|
|
@ -75,7 +75,7 @@ where
|
|||
&& !is_nan_or_infinity(func, args)
|
||||
{
|
||||
self.checks.push((
|
||||
CheckKind::FunctionCallArgumentDefault,
|
||||
CheckKind::FunctionCallArgumentDefault(compose_call_path(expr)),
|
||||
Range::from_located(expr),
|
||||
))
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
source: src/flake8_bugbear/mod.rs
|
||||
expression: checks
|
||||
---
|
||||
- kind: FunctionCallArgumentDefault
|
||||
- kind:
|
||||
FunctionCallArgumentDefault: Depends
|
||||
location:
|
||||
row: 19
|
||||
column: 50
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
source: src/linter.rs
|
||||
expression: checks
|
||||
---
|
||||
- kind: FunctionCallArgumentDefault
|
||||
- kind:
|
||||
FunctionCallArgumentDefault: range
|
||||
location:
|
||||
row: 85
|
||||
column: 60
|
||||
|
@ -10,7 +11,8 @@ expression: checks
|
|||
row: 85
|
||||
column: 68
|
||||
fix: ~
|
||||
- kind: FunctionCallArgumentDefault
|
||||
- kind:
|
||||
FunctionCallArgumentDefault: range
|
||||
location:
|
||||
row: 89
|
||||
column: 63
|
||||
|
@ -18,7 +20,8 @@ expression: checks
|
|||
row: 89
|
||||
column: 71
|
||||
fix: ~
|
||||
- kind: FunctionCallArgumentDefault
|
||||
- kind:
|
||||
FunctionCallArgumentDefault: range
|
||||
location:
|
||||
row: 93
|
||||
column: 59
|
||||
|
@ -26,7 +29,8 @@ expression: checks
|
|||
row: 93
|
||||
column: 67
|
||||
fix: ~
|
||||
- kind: FunctionCallArgumentDefault
|
||||
- kind:
|
||||
FunctionCallArgumentDefault: time.time
|
||||
location:
|
||||
row: 109
|
||||
column: 38
|
||||
|
@ -34,7 +38,8 @@ expression: checks
|
|||
row: 109
|
||||
column: 49
|
||||
fix: ~
|
||||
- kind: FunctionCallArgumentDefault
|
||||
- kind:
|
||||
FunctionCallArgumentDefault: dt.datetime.now
|
||||
location:
|
||||
row: 113
|
||||
column: 11
|
||||
|
@ -42,7 +47,8 @@ expression: checks
|
|||
row: 113
|
||||
column: 28
|
||||
fix: ~
|
||||
- kind: FunctionCallArgumentDefault
|
||||
- kind:
|
||||
FunctionCallArgumentDefault: dt.timedelta
|
||||
location:
|
||||
row: 113
|
||||
column: 31
|
||||
|
@ -50,7 +56,8 @@ expression: checks
|
|||
row: 113
|
||||
column: 51
|
||||
fix: ~
|
||||
- kind: FunctionCallArgumentDefault
|
||||
- kind:
|
||||
FunctionCallArgumentDefault: ~
|
||||
location:
|
||||
row: 117
|
||||
column: 29
|
||||
|
@ -58,7 +65,8 @@ expression: checks
|
|||
row: 117
|
||||
column: 44
|
||||
fix: ~
|
||||
- kind: FunctionCallArgumentDefault
|
||||
- kind:
|
||||
FunctionCallArgumentDefault: float
|
||||
location:
|
||||
row: 155
|
||||
column: 33
|
||||
|
@ -66,7 +74,8 @@ expression: checks
|
|||
row: 155
|
||||
column: 47
|
||||
fix: ~
|
||||
- kind: FunctionCallArgumentDefault
|
||||
- kind:
|
||||
FunctionCallArgumentDefault: float
|
||||
location:
|
||||
row: 160
|
||||
column: 29
|
||||
|
@ -74,7 +83,8 @@ expression: checks
|
|||
row: 160
|
||||
column: 37
|
||||
fix: ~
|
||||
- kind: FunctionCallArgumentDefault
|
||||
- kind:
|
||||
FunctionCallArgumentDefault: float
|
||||
location:
|
||||
row: 164
|
||||
column: 44
|
||||
|
@ -82,7 +92,8 @@ expression: checks
|
|||
row: 164
|
||||
column: 57
|
||||
fix: ~
|
||||
- kind: FunctionCallArgumentDefault
|
||||
- kind:
|
||||
FunctionCallArgumentDefault: float
|
||||
location:
|
||||
row: 170
|
||||
column: 20
|
||||
|
@ -90,7 +101,8 @@ expression: checks
|
|||
row: 170
|
||||
column: 28
|
||||
fix: ~
|
||||
- kind: FunctionCallArgumentDefault
|
||||
- kind:
|
||||
FunctionCallArgumentDefault: dt.datetime.now
|
||||
location:
|
||||
row: 170
|
||||
column: 30
|
||||
|
@ -98,7 +110,8 @@ expression: checks
|
|||
row: 170
|
||||
column: 47
|
||||
fix: ~
|
||||
- kind: FunctionCallArgumentDefault
|
||||
- kind:
|
||||
FunctionCallArgumentDefault: map
|
||||
location:
|
||||
row: 176
|
||||
column: 21
|
||||
|
@ -106,7 +119,8 @@ expression: checks
|
|||
row: 176
|
||||
column: 62
|
||||
fix: ~
|
||||
- kind: FunctionCallArgumentDefault
|
||||
- kind:
|
||||
FunctionCallArgumentDefault: random.randint
|
||||
location:
|
||||
row: 181
|
||||
column: 18
|
||||
|
@ -114,7 +128,8 @@ expression: checks
|
|||
row: 181
|
||||
column: 59
|
||||
fix: ~
|
||||
- kind: FunctionCallArgumentDefault
|
||||
- kind:
|
||||
FunctionCallArgumentDefault: dt.datetime.now
|
||||
location:
|
||||
row: 181
|
||||
column: 36
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue