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 LinterSettings
#7543
Introduce LinterSettings
#7543
Conversation
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
pub show_source: bool, | ||
|
||
pub resolver: ResolverSettings, | ||
pub struct LinterSettings { |
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.
The changes in this file are the main changes. Everything else are just downstream refactors to use the new structure.
862af5c
to
f5511a2
Compare
3d6bc48
to
ed3a426
Compare
f5511a2
to
5d1d3c6
Compare
ignore_init_module_imports: self.ignore_init_module_imports.unwrap_or_default(), | ||
line_length: self.line_length.unwrap_or_default(), | ||
tab_size: self.tab_size.unwrap_or_default(), | ||
namespace_packages: self.namespace_packages.unwrap_or_default(), |
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.
I feel like some of these aren't linter-specific, like namespace_packages
and src
-- they would be generally applicable to any tool that does module / file resolution. But it's not important for now.
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.
That's true, but the Settings
are the resolved view for a tool. My current, not so nice approach, is to duplicate settings that apply to multiple tools when resolving the Configuration
. Meaning, the Configuration
applies` the right inheritance rules and, as a result, may end up initializing common fields identically.
I don't think this is a performance problem because we only do this once per setting and settings tend to not have very large structures.
.map(PyUpgradeOptions::into_settings) | ||
.unwrap_or_default(), | ||
linter: LinterSettings { | ||
target_version, |
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.
Should this be lifted up?
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.
The linter needs access to target_version
. We can't access it if we lift it up. I'll lift it up in the Configuration
, but the each Setting
object needs its own copy of the target_version
.
CodSpeed Performance ReportMerging #7543 will improve performances by 2%Comparing Summary
Benchmarks breakdown
|
ed3a426
to
ae5409e
Compare
5d1d3c6
to
202815b
Compare
LinterSettings
and ResolverSettings
LinterSettings
ae5409e
to
733747c
Compare
4cdd24c
to
0efdc80
Compare
Merge Activity
|
0efdc80
to
308bae8
Compare
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 PR extracts the linter-specific settings into a new
LinterSettings
struct and adds it as alinter
field to theSettings
struct. This is in preparation for movingSettings
fromruff_linter
toruff_workspace
Test Plan
cargo test