mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-27 10:26:26 +00:00
Document link between import-outside-top-level (PLC0415) and lint.flake8-tidy-imports.banned-module-level-imports (#18733)
<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:
- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
requests.)
- Does this pull request include references to any relevant issues?
-->
## Summary
As mentioned in
https://github.com/astral-sh/ruff/issues/18728#issuecomment-2981330666
CC @ntBre


## Test Plan
Run the docs locally as per
a2cd6df429/CONTRIBUTING.md (mkdocs)
---------
Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>
This commit is contained in:
parent
2589a2938e
commit
4f36f0677f
3 changed files with 10 additions and 2 deletions
|
|
@ -44,6 +44,13 @@ use crate::{
|
||||||
/// print(platform.python_version())
|
/// 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
|
/// [PEP 8]: https://peps.python.org/pep-0008/#imports
|
||||||
#[derive(ViolationMetadata)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct ImportOutsideTopLevel;
|
pub(crate) struct ImportOutsideTopLevel;
|
||||||
|
|
|
||||||
|
|
@ -1996,7 +1996,8 @@ pub struct Flake8TidyImportsOptions {
|
||||||
|
|
||||||
/// List of specific modules that may not be imported at module level, and should instead be
|
/// 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:`
|
/// 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(
|
#[option(
|
||||||
default = r#"[]"#,
|
default = r#"[]"#,
|
||||||
value_type = r#"list[str]"#,
|
value_type = r#"list[str]"#,
|
||||||
|
|
|
||||||
2
ruff.schema.json
generated
2
ruff.schema.json
generated
|
|
@ -1438,7 +1438,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"banned-module-level-imports": {
|
"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": [
|
"type": [
|
||||||
"array",
|
"array",
|
||||||
"null"
|
"null"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue