mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
Avoid invalid combination of force-sort-within-types
and lines-between-types
(#9041)
Closes https://github.com/astral-sh/ruff/issues/8792.
This commit is contained in:
parent
981a0703ed
commit
ebc7ac31cb
4 changed files with 39 additions and 2 deletions
|
@ -2109,6 +2109,13 @@ impl IsortOptions {
|
|||
warn_user_once!("`sections` is ignored when `no-sections` is set to `true`");
|
||||
}
|
||||
|
||||
// Verify that if `force_sort_within_sections` is `True`, then `lines_between_types` is set to `0`.
|
||||
let force_sort_within_sections = self.force_sort_within_sections.unwrap_or_default();
|
||||
let lines_between_types = self.lines_between_types.unwrap_or_default();
|
||||
if force_sort_within_sections && lines_between_types != 0 {
|
||||
warn_user_once!("`lines-between-types` is ignored when `force-sort-within-sections` is set to `true`");
|
||||
}
|
||||
|
||||
// Extract any configuration options that deal with user-defined sections.
|
||||
let mut section_order: Vec<_> = self
|
||||
.section_order
|
||||
|
@ -2240,7 +2247,7 @@ impl IsortOptions {
|
|||
required_imports: BTreeSet::from_iter(self.required_imports.unwrap_or_default()),
|
||||
combine_as_imports: self.combine_as_imports.unwrap_or(false),
|
||||
force_single_line: self.force_single_line.unwrap_or(false),
|
||||
force_sort_within_sections: self.force_sort_within_sections.unwrap_or(false),
|
||||
force_sort_within_sections,
|
||||
case_sensitive: self.case_sensitive.unwrap_or(false),
|
||||
force_wrap_aliases: self.force_wrap_aliases.unwrap_or(false),
|
||||
detect_same_package: self.detect_same_package.unwrap_or(true),
|
||||
|
@ -2263,7 +2270,7 @@ impl IsortOptions {
|
|||
variables: BTreeSet::from_iter(self.variables.unwrap_or_default()),
|
||||
no_lines_before: BTreeSet::from_iter(no_lines_before),
|
||||
lines_after_imports: self.lines_after_imports.unwrap_or(-1),
|
||||
lines_between_types: self.lines_between_types.unwrap_or_default(),
|
||||
lines_between_types,
|
||||
forced_separate: Vec::from_iter(self.forced_separate.unwrap_or_default()),
|
||||
section_order,
|
||||
no_sections,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue