-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Introduce FormatterSettings
#7545
Conversation
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
CodSpeed Performance ReportMerging #7545 will not alter performanceComparing Summary
|
let options = PyFormatOptions::from_source_type(source_type) | ||
.with_line_width(LineWidth::from(NonZeroU16::from(line_length))) | ||
.with_preview(preview); | ||
let options = resolved_settings.formatter.to_format_options(source_type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All just for this 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's beautiful
030293a
to
9452ec3
Compare
a411af8
to
c5cfb8a
Compare
9452ec3
to
6cc6cee
Compare
c5cfb8a
to
8c775c1
Compare
6cc6cee
to
4323547
Compare
8c775c1
to
e93aeb4
Compare
4323547
to
e1aa031
Compare
e93aeb4
to
c3489e4
Compare
2421373
to
1ebf2ea
Compare
c3489e4
to
2a6ee1d
Compare
2a6ee1d
to
e9cbfab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent.
PR Check ResultsEcosystem✅ ecosystem check detected no changes. |
Stack Summary
This stack splits
Settings
intoFormatterSettings
andLinterSettings
and moves it intoruff_workspace
. This change is necessary to add theFormatterSettings
toSettings
without addingruff_python_formatter
as a dependency toruff_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 thepyproject.toml
orruff.toml
. Used for deserialization.Configuration
: ResolvedOptions
, potentially merged from multiple configurations (when usingextend
). The representation is very close if not identical to theOptions
.Settings
: The resolved configuration that uses a data format optimized for reading. Optional fields are initialized with their default values. Initialized byConfiguration::into_settings
.The goal of this stack is to split
Settings
into tool-specific resolvedSettings
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 betweenSettings
. 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
. SplittingConfiguration
into some smaller structs is something I'll follow up on later.PR Summary
This is the final step for the settings related structure changes. This PR introduces a new
FormatterSettings
struct inruff_python_formatter
and populates it inConfiguration::into_settings
. This PR doesn't add new options yet (still only supports settingline_width
).Test Plan
cargo test
main
with caching. The numbers remain unchanged, proving that the cache is working