-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Rename *-length
options to -width
#8010
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
//! Extract Black configuration settings from a pyproject.toml. | ||
|
||
use ruff_linter::line_width::LineLength; | ||
use ruff_linter::line_width::LineWidth; | ||
use ruff_linter::settings::types::PythonVersion; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Default)] | ||
pub(crate) struct Black { | ||
#[serde(alias = "line-length", alias = "line_length")] | ||
pub(crate) line_length: Option<LineLength>, | ||
pub(crate) line_length: Option<LineWidth>, | ||
#[serde(alias = "target-version", alias = "target_version")] | ||
pub(crate) target_version: Option<Vec<PythonVersion>>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ use clap::{command, Parser}; | |
use regex::Regex; | ||
use rustc_hash::FxHashMap; | ||
|
||
use ruff_linter::line_width::LineLength; | ||
use ruff_linter::line_width::LineWidth; | ||
use ruff_linter::logging::LogLevel; | ||
use ruff_linter::registry::Rule; | ||
use ruff_linter::settings::types::{ | ||
|
@@ -259,9 +259,15 @@ pub struct CheckCommand { | |
force_exclude: bool, | ||
#[clap(long, overrides_with("force_exclude"), hide = true)] | ||
no_force_exclude: bool, | ||
/// Set the line-length for length-associated rules and automatic formatting. | ||
/// Set the line-width for width-associated rules. | ||
#[arg(long, help_heading = "Rule configuration", hide = true)] | ||
pub line_length: Option<LineLength>, | ||
pub line_width: Option<LineWidth>, | ||
|
||
/// Set the line-length for width-associated rules. | ||
#[arg(long, help_heading = "Rule configuration", hide = true)] | ||
#[deprecated(note = "Deprecated in favor of `--line-width`")] | ||
pub line_length: Option<LineWidth>, | ||
|
||
/// Regular expression matching the name of dummy variables. | ||
#[arg(long, help_heading = "Rule configuration", hide = true)] | ||
pub dummy_variable_rgx: Option<Regex>, | ||
|
@@ -389,9 +395,6 @@ pub struct FormatCommand { | |
force_exclude: bool, | ||
#[clap(long, overrides_with("force_exclude"), hide = true)] | ||
no_force_exclude: bool, | ||
/// Set the line-length. | ||
#[arg(long, help_heading = "Rule configuration", hide = true)] | ||
pub line_length: Option<LineLength>, | ||
Comment on lines
-392
to
-394
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed this option from the formatter. I don't remember us explicitly deciding on exposing it and it was a hidden option anyway. |
||
/// Ignore all configuration files. | ||
#[arg(long, conflicts_with = "config", help_heading = "Miscellaneous")] | ||
pub isolated: bool, | ||
|
@@ -465,6 +468,9 @@ impl CheckCommand { | |
/// Partition the CLI into command-line arguments and configuration | ||
/// overrides. | ||
pub fn partition(self) -> (CheckArguments, CliOverrides) { | ||
#[allow(deprecated)] | ||
let line_width = self.line_width.or(self.line_length); | ||
|
||
( | ||
CheckArguments { | ||
add_noqa: self.add_noqa, | ||
|
@@ -494,7 +500,7 @@ impl CheckCommand { | |
extend_unfixable: self.extend_unfixable, | ||
fixable: self.fixable, | ||
ignore: self.ignore, | ||
line_length: self.line_length, | ||
line_width, | ||
per_file_ignores: self.per_file_ignores, | ||
preview: resolve_bool_arg(self.preview, self.no_preview).map(PreviewMode::from), | ||
respect_gitignore: resolve_bool_arg( | ||
|
@@ -533,7 +539,7 @@ impl FormatCommand { | |
stdin_filename: self.stdin_filename, | ||
}, | ||
CliOverrides { | ||
line_length: self.line_length, | ||
line_width: None, | ||
respect_gitignore: resolve_bool_arg( | ||
self.respect_gitignore, | ||
self.no_respect_gitignore, | ||
|
@@ -605,7 +611,7 @@ pub struct CliOverrides { | |
pub extend_unfixable: Option<Vec<RuleSelector>>, | ||
pub fixable: Option<Vec<RuleSelector>>, | ||
pub ignore: Option<Vec<RuleSelector>>, | ||
pub line_length: Option<LineLength>, | ||
pub line_width: Option<LineWidth>, | ||
pub per_file_ignores: Option<Vec<PatternPrefixPair>>, | ||
pub preview: Option<PreviewMode>, | ||
pub respect_gitignore: Option<bool>, | ||
|
@@ -672,8 +678,8 @@ impl ConfigurationTransformer for CliOverrides { | |
if let Some(force_exclude) = &self.force_exclude { | ||
config.force_exclude = Some(*force_exclude); | ||
} | ||
if let Some(line_length) = &self.line_length { | ||
config.line_length = Some(*line_length); | ||
if let Some(line_width) = self.line_width { | ||
config.line_width = Some(line_width); | ||
} | ||
if let Some(preview) = &self.preview { | ||
config.preview = Some(*preview); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
crates/ruff_linter/resources/test/fixtures/isort/detect_same_package/pyproject.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[tool.ruff] | ||
line-length = 88 | ||
line-width = 88 |
2 changes: 1 addition & 1 deletion
2
crates/ruff_linter/resources/test/fixtures/isort/pyproject.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[tool.ruff] | ||
line-length = 88 | ||
line-width = 88 | ||
|
||
[tool.ruff.isort] | ||
lines-after-imports = 3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[tool.ruff] | ||
line-length = 88 | ||
line-width = 88 | ||
extend-exclude = [ | ||
"excluded_file.py", | ||
"migrations", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm assuming that the
line_length
here wasn't renamed because it's coming from flake8?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.
Yes, these are the options of the source configuration that gets rewritten to ruff.