Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Settings and ResolverSettings to ruff_workspace #7544

Merged
merged 1 commit into from Sep 20, 2023

Conversation

MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Sep 20, 2023

Summary

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 moves the ResolverSettings and Settings struct to ruff_workspace. LinterSettings remains in ruff_linter because it gets passed to lint rules, the Checker etc.

Test Plan

cargo test

This was referenced Sep 20, 2023
@codspeed-hq
Copy link

codspeed-hq bot commented Sep 20, 2023

CodSpeed Performance Report

Merging #7544 will not alter performance

Comparing move-settings-to-ruff-workspace (1ebf2ea) with main (b34278e)

Summary

✅ 25 untouched benchmarks

@MichaReiser MichaReiser force-pushed the linter-settings branch 2 times, most recently from f5511a2 to 5d1d3c6 Compare September 20, 2023 12:58
@MichaReiser MichaReiser marked this pull request as ready for review September 20, 2023 12:58
@MichaReiser MichaReiser added the internal An internal refactor or improvement label Sep 20, 2023
Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, that's an impressive refactor.

@MichaReiser
Copy link
Member Author

MichaReiser commented Sep 20, 2023

Merge Activity

  • Sep 20, 11:05 AM: Graphite rebased this pull request after merging its parent, because this pull request is set to merge when ready.
  • Sep 20, 11:24 AM: @MichaReiser merged this pull request with Graphite.

@github-actions
Copy link
Contributor

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

@MichaReiser MichaReiser merged commit 6540321 into main Sep 20, 2023
16 checks passed
@MichaReiser MichaReiser deleted the move-settings-to-ruff-workspace branch September 20, 2023 15:24
@samschlegel
Copy link

One followup here is that I think the paths in CONTRIBUTING.md need to be updated to reference these structs?

@charliermarsh
Copy link
Member

@samschlegel - Great catch, thanks! PR welcome or I can fix it up :)

@samschlegel
Copy link

@samschlegel - Great catch, thanks! PR welcome or I can fix it up :)

I ran into it while reading it and I'm not entirely sure what's moved where so would probably be easier for you to do at the moment 😅

@charliermarsh
Copy link
Member

It looks like a few things are out-of-date in that section so I'll do some clean-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal An internal refactor or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants