mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 20:42:10 +00:00
[flake8-builtins
] Disapply A005
to stub files (#15350)
This commit is contained in:
parent
1447553bc2
commit
ee9a912f47
4 changed files with 14 additions and 1 deletions
|
@ -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
|
||||
---
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue