mirror of
https://github.com/astral-sh/ruff
synced 2026-01-20 21:10:48 -05:00
Split checks and plugins into source-related modules (#447)
This commit is contained in:
20
src/flake8_builtins/checks.rs
Normal file
20
src/flake8_builtins/checks.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use crate::ast::types::Range;
|
||||
use crate::checks::{Check, CheckKind};
|
||||
use crate::flake8_builtins::types::ShadowingType;
|
||||
use crate::python::builtins::BUILTINS;
|
||||
|
||||
/// Check builtin name shadowing.
|
||||
pub fn builtin_shadowing(name: &str, location: Range, node_type: ShadowingType) -> Option<Check> {
|
||||
if BUILTINS.contains(&name) {
|
||||
Some(Check::new(
|
||||
match node_type {
|
||||
ShadowingType::Variable => CheckKind::BuiltinVariableShadowing(name.to_string()),
|
||||
ShadowingType::Argument => CheckKind::BuiltinArgumentShadowing(name.to_string()),
|
||||
ShadowingType::Attribute => CheckKind::BuiltinAttributeShadowing(name.to_string()),
|
||||
},
|
||||
location,
|
||||
))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
2
src/flake8_builtins/mod.rs
Normal file
2
src/flake8_builtins/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod checks;
|
||||
pub mod types;
|
||||
5
src/flake8_builtins/types.rs
Normal file
5
src/flake8_builtins/types.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
pub enum ShadowingType {
|
||||
Variable,
|
||||
Argument,
|
||||
Attribute,
|
||||
}
|
||||
Reference in New Issue
Block a user