mirror of
https://github.com/astral-sh/ruff.git
synced 2025-12-01 16:41:56 +00:00
Improve documentation around custom isort sections (#11050)
## Summary Closes https://github.com/astral-sh/ruff/issues/11047.
This commit is contained in:
parent
7b3c92a979
commit
99f7f94538
2 changed files with 26 additions and 2 deletions
|
|
@ -2257,7 +2257,31 @@ pub struct IsortOptions {
|
||||||
|
|
||||||
// Tables are required to go last.
|
// Tables are required to go last.
|
||||||
/// A list of mappings from section names to modules.
|
/// A list of mappings from section names to modules.
|
||||||
/// By default custom sections are output last, but this can be overridden with `section-order`.
|
///
|
||||||
|
/// By default, imports are categorized according to their type (e.g., `future`, `third-party`,
|
||||||
|
/// and so on). This setting allows you to group modules into custom sections, to augment or
|
||||||
|
/// override the built-in sections.
|
||||||
|
///
|
||||||
|
/// For example, to group all testing utilities, you could create a `testing` section:
|
||||||
|
/// ```toml
|
||||||
|
/// testing = ["pytest", "hypothesis"]
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// Custom sections should typically be inserted into the `section-order` list to ensure that
|
||||||
|
/// they're displayed as a standalone group and in the intended order, as in:
|
||||||
|
/// ```toml
|
||||||
|
/// section-order = [
|
||||||
|
/// "future",
|
||||||
|
/// "standard-library",
|
||||||
|
/// "third-party",
|
||||||
|
/// "first-party",
|
||||||
|
/// "local-folder",
|
||||||
|
/// "testing"
|
||||||
|
/// ]
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// If a custom section is omitted from `section-order`, imports in that section will be
|
||||||
|
/// assigned to the `default-section` (which defaults to `third-party`).
|
||||||
#[option(
|
#[option(
|
||||||
default = "{}",
|
default = "{}",
|
||||||
value_type = "dict[str, list[str]]",
|
value_type = "dict[str, list[str]]",
|
||||||
|
|
|
||||||
2
ruff.schema.json
generated
2
ruff.schema.json
generated
|
|
@ -1698,7 +1698,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sections": {
|
"sections": {
|
||||||
"description": "A list of mappings from section names to modules. By default custom sections are output last, but this can be overridden with `section-order`.",
|
"description": "A list of mappings from section names to modules.\n\nBy default, imports are categorized according to their type (e.g., `future`, `third-party`, and so on). This setting allows you to group modules into custom sections, to augment or override the built-in sections.\n\nFor example, to group all testing utilities, you could create a `testing` section: ```toml testing = [\"pytest\", \"hypothesis\"] ```\n\nCustom sections should typically be inserted into the `section-order` list to ensure that they're displayed as a standalone group and in the intended order, as in: ```toml section-order = [ \"future\", \"standard-library\", \"third-party\", \"first-party\", \"local-folder\", \"testing\" ] ```\n\nIf a custom section is omitted from `section-order`, imports in that section will be assigned to the `default-section` (which defaults to `third-party`).",
|
||||||
"type": [
|
"type": [
|
||||||
"object",
|
"object",
|
||||||
"null"
|
"null"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue