[flake8-builtins] Disapply A005 to stub files (#15350)
This commit is contained in:
@@ -0,0 +1 @@
|
||||
# A005 does not apply to stub files!
|
||||
@@ -36,6 +36,10 @@ mod tests {
|
||||
Rule::StdlibModuleShadowing,
|
||||
Path::new("A005/modules/package/bisect.py")
|
||||
)]
|
||||
#[test_case(
|
||||
Rule::StdlibModuleShadowing,
|
||||
Path::new("A005/modules/package/collections.pyi")
|
||||
)]
|
||||
#[test_case(
|
||||
Rule::StdlibModuleShadowing,
|
||||
Path::new("A005/modules/_abc/__init__.py")
|
||||
|
||||
@@ -23,6 +23,10 @@ use crate::settings::types::PythonVersion;
|
||||
/// Standard-library modules can be marked as exceptions to this rule via the
|
||||
/// [`lint.flake8-builtins.builtins-allowed-modules`] configuration option.
|
||||
///
|
||||
/// This rule is not applied to stub files, as the name of a stub module is out
|
||||
/// of the control of the author of the stub file. Instead, a stub should aim to
|
||||
/// faithfully emulate the runtime module it is stubbing.
|
||||
///
|
||||
/// ## Options
|
||||
/// - `lint.flake8-builtins.builtins-allowed-modules`
|
||||
#[derive(ViolationMetadata)]
|
||||
@@ -45,7 +49,7 @@ pub(crate) fn stdlib_module_shadowing(
|
||||
allowed_modules: &[String],
|
||||
target_version: PythonVersion,
|
||||
) -> Option<Diagnostic> {
|
||||
if !PySourceType::try_from_path(path).is_some_and(PySourceType::is_py_file_or_stub) {
|
||||
if !PySourceType::try_from_path(path).is_some_and(PySourceType::is_py_file) {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user