Skip to content

Commit e99f284

Browse files
committed
Avoid collision with A002
1 parent 77be734 commit e99f284

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/ruff_linter/src/rules/ruff/rules/overshadowing_parameter.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ use crate::rules::flake8_pytest_style::rules::fixture_decorator;
1414
/// Having two symbols with the same name is confusing and may lead to bugs.
1515
///
1616
/// As an exception, parameters referencing Pytest fixtures are ignored.
17+
/// Parameters shadowing built-in symbols (e.g., `id` or `type`)
18+
/// are also not reported, as they are within the scope of [`builtin-argument-shadowing`][A002].
1719
///
1820
/// ## Example
1921
///
@@ -34,6 +36,8 @@ use crate::rules::flake8_pytest_style::rules::fixture_decorator;
3436
/// def f(b):
3537
/// print(b)
3638
/// ```
39+
///
40+
/// [A002]: https://docs.astral.sh/ruff/rules/builtin-argument-shadowing
3741
#[derive(ViolationMetadata)]
3842
pub(crate) struct OvershadowingParameter;
3943

@@ -61,6 +65,11 @@ pub(crate) fn overshadowing_parameter(checker: &Checker, binding: &Binding) -> O
6165
return None;
6266
}
6367

68+
// Parameters shadowing builtins are already reported by A005
69+
if semantic.binding(overshadowed).kind.is_builtin() {
70+
return None;
71+
}
72+
6473
Some(Diagnostic::new(OvershadowingParameter, binding.range))
6574
}
6675

0 commit comments

Comments
 (0)