Skip to content

Commit f8093b6

Browse files
authored
[flake8-builtins] Update documentation (A005) (#16097)
Follow-up to #15951 to update * the options links in A005 to reference `lint.flake8-builtins.builtins-strict-checking` * the description of the rule to explain strict vs non-strict checking * the option documentation to point back to the rule
1 parent c31352f commit f8093b6

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

crates/ruff_linter/src/rules/flake8_builtins/rules/stdlib_module_shadowing.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ use crate::settings::LinterSettings;
2323
/// Standard-library modules can be marked as exceptions to this rule via the
2424
/// [`lint.flake8-builtins.builtins-allowed-modules`] configuration option.
2525
///
26+
/// By default, only the last component of the module name is considered, so `logging.py`,
27+
/// `utils/logging.py`, and `utils/logging/__init__.py` would all clash with the builtin `logging`
28+
/// module. With the [`lint.flake8-builtins.builtins-strict-checking`] option set to `false`, the
29+
/// module path is considered, so only a top-level `logging.py` or `logging/__init__.py` will
30+
/// trigger the rule and `utils/logging.py`, for example, would not. In preview mode, the default
31+
/// value of [`lint.flake8-builtins.builtins-strict-checking`] is `false` rather than `true` in
32+
/// stable mode.
33+
///
2634
/// This rule is not applied to stub files, as the name of a stub module is out
2735
/// of the control of the author of the stub file. Instead, a stub should aim to
2836
/// faithfully emulate the runtime module it is stubbing.
@@ -43,6 +51,7 @@ use crate::settings::LinterSettings;
4351
///
4452
/// ## Options
4553
/// - `lint.flake8-builtins.builtins-allowed-modules`
54+
/// - `lint.flake8-builtins.builtins-strict-checking`
4655
#[derive(ViolationMetadata)]
4756
pub(crate) struct StdlibModuleShadowing {
4857
name: String,

crates/ruff_workspace/src/options.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,10 @@ pub struct Flake8BuiltinsOptions {
11491149
example = "builtins-strict-checking = false"
11501150
)]
11511151
/// Compare module names instead of full module paths.
1152+
///
1153+
/// Used by [`A005` - `stdlib-module-shadowing`](https://docs.astral.sh/ruff/rules/stdlib-module-shadowing/).
1154+
///
1155+
/// In preview mode the default value is `false` rather than `true`.
11521156
pub builtins_strict_checking: Option<bool>,
11531157
}
11541158

ruff.schema.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)