mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-19 19:15:30 +00:00
Introduce LinterSettings
## Stack Summary This stack splits `Settings` into `FormatterSettings` and `LinterSettings` and moves it into `ruff_workspace`. This change is necessary to add the `FormatterSettings` to `Settings` without adding `ruff_python_formatter` as a dependency to `ruff_linter` (and the linter should not contain the formatter settings). A quick overview of our settings struct at play: * `Options`: 1:1 representation of the options in the `pyproject.toml` or `ruff.toml`. Used for deserialization. * `Configuration`: Resolved `Options`, potentially merged from multiple configurations (when using `extend`). The representation is very close if not identical to the `Options`. * `Settings`: The resolved configuration that uses a data format optimized for reading. Optional fields are initialized with their default values. Initialized by `Configuration::into_settings` . The goal of this stack is to split `Settings` into tool-specific resolved `Settings` that are independent of each other. This comes at the advantage that the individual crates don't need to know anything about the other tools. The downside is that information gets duplicated between `Settings`. Right now the duplication is minimal (`line-length`, `tab-width`) but we may need to come up with a solution if more expensive data needs sharing. This stack focuses on `Settings`. Splitting `Configuration` into some smaller structs is something I'll follow up on later. ## PR Summary This PR extracts the linter-specific settings into a new `LinterSettings` struct and adds it as a `linter` field to the `Settings` struct. This is in preparation for moving `Settings` from `ruff_linter` to `ruff_workspace` ## Test Plan `cargo test`
This commit is contained in:
parent
222f1c37b8
commit
b34278e0cd
101 changed files with 753 additions and 716 deletions
|
@ -550,8 +550,11 @@ fn format_dir_entry(
|
|||
|
||||
let settings = resolver.resolve(&path, pyproject_config);
|
||||
// That's a bad way of doing this but it's not worth doing something better for format_dev
|
||||
if settings.line_length != LineLength::default() {
|
||||
options = options.with_line_width(LineWidth::from(NonZeroU16::from(settings.line_length)));
|
||||
// TODO(micha) use formatter settings instead
|
||||
if settings.linter.line_length != LineLength::default() {
|
||||
options = options.with_line_width(LineWidth::from(NonZeroU16::from(
|
||||
settings.linter.line_length,
|
||||
)));
|
||||
}
|
||||
|
||||
// Handle panics (mostly in `debug_assert!`)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue