[flake8-bugbear] - do not run mutable-argument-default on stubs (B006) (#14058)
## Summary Early-exits in `B006` when the file is a stub. Fixes #14026 ## Test Plan `cargo test`
This commit is contained in:
10
crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B006_1.pyi
vendored
Normal file
10
crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B006_1.pyi
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
# we disable this rule for pyi files
|
||||
|
||||
def mquantiles(
|
||||
a: _ArrayLikeFloat_co,
|
||||
prob: _ArrayLikeFloat_co = [0.25, 0.5, 0.75],
|
||||
alphap: AnyReal = 0.4,
|
||||
betap: AnyReal = 0.4,
|
||||
axis: CanIndex | None = None,
|
||||
limit: tuple[AnyReal, AnyReal] | tuple[()] = (),
|
||||
) -> _MArrayND: ...
|
||||
@@ -43,6 +43,7 @@ mod tests {
|
||||
#[test_case(Rule::MutableArgumentDefault, Path::new("B006_7.py"))]
|
||||
#[test_case(Rule::MutableArgumentDefault, Path::new("B006_8.py"))]
|
||||
#[test_case(Rule::MutableArgumentDefault, Path::new("B006_B008.py"))]
|
||||
#[test_case(Rule::MutableArgumentDefault, Path::new("B006_1.pyi"))]
|
||||
#[test_case(Rule::NoExplicitStacklevel, Path::new("B028.py"))]
|
||||
#[test_case(Rule::RaiseLiteral, Path::new("B016.py"))]
|
||||
#[test_case(Rule::RaiseWithoutFromInsideExcept, Path::new("B904.py"))]
|
||||
|
||||
@@ -86,6 +86,11 @@ impl Violation for MutableArgumentDefault {
|
||||
|
||||
/// B006
|
||||
pub(crate) fn mutable_argument_default(checker: &mut Checker, function_def: &ast::StmtFunctionDef) {
|
||||
// Skip stub files
|
||||
if checker.source_type.is_stub() {
|
||||
return;
|
||||
}
|
||||
|
||||
for ParameterWithDefault {
|
||||
parameter,
|
||||
default,
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user