diff --git a/crates/ruff_linter/src/rules/pylint/rules/import_outside_top_level.rs b/crates/ruff_linter/src/rules/pylint/rules/import_outside_top_level.rs index b8bc8a5952..57b7fd2b27 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/import_outside_top_level.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/import_outside_top_level.rs @@ -44,6 +44,13 @@ use crate::{ /// print(platform.python_version()) /// ``` /// +/// ## See also +/// This rule will ignore import statements configured in +/// [`lint.flake8-tidy-imports.banned-module-level-imports`][banned-module-level-imports] +/// if the rule [`banned-module-level-imports`][TID253] is enabled. +/// +/// [banned-module-level-imports]: https://docs.astral.sh/ruff/settings/#lint_flake8-tidy-imports_banned-module-level-imports +/// [TID253]: https://docs.astral.sh/ruff/rules/banned-module-level-imports/ /// [PEP 8]: https://peps.python.org/pep-0008/#imports #[derive(ViolationMetadata)] pub(crate) struct ImportOutsideTopLevel; diff --git a/crates/ruff_workspace/src/options.rs b/crates/ruff_workspace/src/options.rs index 8c6b630f28..a6a10a3493 100644 --- a/crates/ruff_workspace/src/options.rs +++ b/crates/ruff_workspace/src/options.rs @@ -1996,7 +1996,8 @@ pub struct Flake8TidyImportsOptions { /// List of specific modules that may not be imported at module level, and should instead be /// imported lazily (e.g., within a function definition, or an `if TYPE_CHECKING:` - /// block, or some other nested context). + /// block, or some other nested context). This also affects the rule `import-outside-top-level` + /// if `banned-module-level-imports` is enabled. #[option( default = r#"[]"#, value_type = r#"list[str]"#, diff --git a/ruff.schema.json b/ruff.schema.json index 6e64471f93..dc65015dd0 100644 --- a/ruff.schema.json +++ b/ruff.schema.json @@ -1438,7 +1438,7 @@ } }, "banned-module-level-imports": { - "description": "List of specific modules that may not be imported at module level, and should instead be imported lazily (e.g., within a function definition, or an `if TYPE_CHECKING:` block, or some other nested context).", + "description": "List of specific modules that may not be imported at module level, and should instead be imported lazily (e.g., within a function definition, or an `if TYPE_CHECKING:` block, or some other nested context). This also affects the rule `import-outside-top-level` if `banned-module-level-imports` is enabled.", "type": [ "array", "null"