mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
[flake8-builtins
] Implement import, lambda, and module shadowing (#12546)
## Summary <!-- What's the purpose of the change? What does it do, and why? --> Extend `flake8-builtins` to imports, lambda-arguments, and modules to be consistent with original checker [flake8_builtins](https://github.com/gforcada/flake8-builtins/blob/main/flake8_builtins.py). closes #12540 ## Details - Implement builtin-import-shadowing (A004) - Stop tracking imports shadowing in builtin-variable-shadowing (A001) in preview mode. - Implement builtin-lambda-argument-shadowing (A005) - Implement builtin-module-shadowing (A006) - Add new option `linter.flake8_builtins.builtins_allowed_modules` ## Test Plan cargo test
This commit is contained in:
parent
665c75f7ab
commit
9cdc578dd9
41 changed files with 589 additions and 24 deletions
|
@ -1104,12 +1104,20 @@ pub struct Flake8BuiltinsOptions {
|
|||
)]
|
||||
/// Ignore list of builtins.
|
||||
pub builtins_ignorelist: Option<Vec<String>>,
|
||||
#[option(
|
||||
default = r#"[]"#,
|
||||
value_type = "list[str]",
|
||||
example = "builtins-allowed-modules = [\"id\"]"
|
||||
)]
|
||||
/// List of builtin module names to allow.
|
||||
pub builtins_allowed_modules: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
impl Flake8BuiltinsOptions {
|
||||
pub fn into_settings(self) -> ruff_linter::rules::flake8_builtins::settings::Settings {
|
||||
ruff_linter::rules::flake8_builtins::settings::Settings {
|
||||
builtins_ignorelist: self.builtins_ignorelist.unwrap_or_default(),
|
||||
builtins_allowed_modules: self.builtins_allowed_modules.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue