Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flake8-builtins] Update documentation (A005) #16097

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ use crate::settings::LinterSettings;
/// Standard-library modules can be marked as exceptions to this rule via the
/// [`lint.flake8-builtins.builtins-allowed-modules`] configuration option.
///
/// By default, only the last component of the module name is considered, so `logging.py`,
/// `a/logging.py`, `a/b/logging.py`, and so on would all clash with the builtin `logging` module.
/// With the [`lint.flake8-builtins.builtins-strict-checking`] option set to `false`, the module
/// path is considered, so only a top-level `logging.py` or `logging/__init__.py` will trigger the
/// rule and `utils/logging.py`, for example, would not.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps re-use example from above a/logging.py (or use the utils/logging.py example above)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's a good idea, thanks! I went for a consistent use of the logging example:

/// By default, only the last component of the module name is considered, so `logging.py`,
/// `utils/logging.py`, and `utils/logging/__init__.py` would all clash with the builtin `logging`
/// module. With the [`lint.flake8-builtins.builtins-strict-checking`] option set to `false`, the
/// module path is considered, so only a top-level `logging.py` or `logging/__init__.py` will
/// trigger the rule and `utils/logging.py`, for example, would not.

What do you think?

///
/// 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.
Expand All @@ -43,6 +49,7 @@ use crate::settings::LinterSettings;
///
/// ## Options
/// - `lint.flake8-builtins.builtins-allowed-modules`
/// - `lint.flake8-builtins.builtins-strict-checking`
#[derive(ViolationMetadata)]
pub(crate) struct StdlibModuleShadowing {
name: String,
Expand Down
2 changes: 2 additions & 0 deletions crates/ruff_workspace/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,8 @@ pub struct Flake8BuiltinsOptions {
example = "builtins-strict-checking = false"
)]
/// Compare module names instead of full module paths.
///
/// Used by [`A005` - `stdlib-module-shadowing`](https://docs.astral.sh/ruff/rules/stdlib-module-shadowing/).
pub builtins_strict_checking: Option<bool>,
}

Expand Down
2 changes: 1 addition & 1 deletion ruff.schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading