Skip to content

Commit

Permalink
remove line-width option from LinterSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Oct 19, 2023
1 parent 09f842a commit 710f0a3
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pub(crate) fn multiple_with_statements(
content,
with_stmt.into(),
checker.locator(),
checker.settings.line_width,
checker.settings.pycodestyle.max_line_width,
checker.settings.tab_size,
)
}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub(crate) fn nested_if_statements(
content,
(&nested_if).into(),
checker.locator(),
checker.settings.line_width,
checker.settings.pycodestyle.max_line_width,
checker.settings.tab_size,
)
}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ pub(crate) fn use_dict_get_with_default(checker: &mut Checker, stmt_if: &ast::St
&contents,
stmt_if.into(),
checker.locator(),
checker.settings.line_width,
checker.settings.pycodestyle.max_line_width,
checker.settings.tab_size,
) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub(crate) fn use_ternary_operator(checker: &mut Checker, stmt: &Stmt) {
&contents,
stmt.into(),
checker.locator(),
checker.settings.line_width,
checker.settings.pycodestyle.max_line_width,
checker.settings.tab_size,
) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub(crate) fn convert_for_loop_to_any_all(checker: &mut Checker, stmt: &Stmt) {
&contents,
stmt.into(),
checker.locator(),
checker.settings.line_width,
checker.settings.pycodestyle.max_line_width,
checker.settings.tab_size,
) {
return;
Expand Down Expand Up @@ -188,7 +188,7 @@ pub(crate) fn convert_for_loop_to_any_all(checker: &mut Checker, stmt: &Stmt) {
.slice(TextRange::new(line_start, stmt.start())),
)
.add_str(&contents)
> checker.settings.line_width
> checker.settings.pycodestyle.max_line_width
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub(crate) fn organize_imports(
block,
comments,
locator,
settings.line_width,
settings.pycodestyle.max_line_width,
LineWidthBuilder::new(settings.tab_size).add_str(indentation),
stylist,
&settings.src,
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_linter/src/rules/pyupgrade/rules/f_strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ pub(crate) fn f_strings(
&contents,
template.into(),
checker.locator(),
checker.settings.line_width,
checker.settings.pycodestyle.max_line_width,
checker.settings.tab_size,
) {
return;
Expand Down
4 changes: 1 addition & 3 deletions crates/ruff_linter/src/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::rules::{
use crate::settings::types::{FilePatternSet, PerFileIgnore, PythonVersion};
use crate::{codes, RuleSelector};

use super::line_width::{LineWidth, TabSize};
use super::line_width::TabSize;

use self::rule_table::RuleTable;
use self::types::PreviewMode;
Expand Down Expand Up @@ -56,7 +56,6 @@ pub struct LinterSettings {
pub dummy_variable_rgx: Regex,
pub external: FxHashSet<String>,
pub ignore_init_module_imports: bool,
pub line_width: LineWidth,
pub logger_objects: Vec<String>,
pub namespace_packages: Vec<PathBuf>,
pub src: Vec<PathBuf>,
Expand Down Expand Up @@ -147,7 +146,6 @@ impl LinterSettings {

external: HashSet::default(),
ignore_init_module_imports: false,
line_width: LineWidth::default(),
logger_objects: vec![],
namespace_packages: vec![],

Expand Down
14 changes: 9 additions & 5 deletions crates/ruff_workspace/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use ruff_linter::line_width::{LineWidth, TabSize};
use ruff_linter::registry::RuleNamespace;
use ruff_linter::registry::{Rule, RuleSet, INCOMPATIBLE_CODES};
use ruff_linter::rule_selector::{PreviewOptions, Specificity};
use ruff_linter::rules::pycodestyle;
use ruff_linter::settings::rule_table::RuleTable;
use ruff_linter::settings::types::{
FilePattern, FilePatternSet, PerFileIgnore, PreviewMode, PythonVersion, SerializationFormat,
Expand Down Expand Up @@ -225,7 +226,6 @@ impl Configuration {
.unwrap_or_else(|| DUMMY_VARIABLE_RGX.clone()),
external: FxHashSet::from_iter(lint.external.unwrap_or_default()),
ignore_init_module_imports: lint.ignore_init_module_imports.unwrap_or_default(),
line_width,
tab_size: self.tab_size.unwrap_or_default(),
namespace_packages: self.namespace_packages.unwrap_or_default(),
per_file_ignores: resolve_per_file_ignores(
Expand Down Expand Up @@ -346,10 +346,14 @@ impl Configuration {
.map(Pep8NamingOptions::try_into_settings)
.transpose()?
.unwrap_or_default(),
pycodestyle: lint
.pycodestyle
.map(|options| options.into_settings(line_width))
.unwrap_or_default(),
pycodestyle: if let Some(pycodestyle) = lint.pycodestyle {
pycodestyle.into_settings(line_width)
} else {
pycodestyle::settings::Settings {
max_line_width: line_width,
..pycodestyle::settings::Settings::default()
}
},
pydocstyle: lint
.pydocstyle
.map(PydocstyleOptions::into_settings)
Expand Down
16 changes: 7 additions & 9 deletions crates/ruff_workspace/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct Options {
/// this base configuration file, then merge in any properties defined
/// in the current configuration file.
#[option(
default = r#"None"#,
default = r#"null"#,
value_type = "str",
example = r#"
# Extend the `pyproject.toml` file in the parent directory.
Expand Down Expand Up @@ -132,7 +132,7 @@ pub struct Options {
/// results across many environments, e.g., with a `pyproject.toml`
/// file).
#[option(
default = "None",
default = "null",
value_type = "str",
example = r#"
required-version = "0.0.193"
Expand Down Expand Up @@ -1062,7 +1062,7 @@ pub struct Flake8CopyrightOptions {

/// Author to enforce within the copyright notice. If provided, the
/// author must be present immediately following the copyright notice.
#[option(default = "None", value_type = "str", example = r#"author = "Ruff""#)]
#[option(default = "null", value_type = "str", example = r#"author = "Ruff""#)]
pub author: Option<String>,

/// A minimum file size (in bytes) required for a copyright notice to
Expand Down Expand Up @@ -2269,8 +2269,8 @@ pub struct PycodestyleOptions {
/// The maximum [width](http://www.unicode.org/reports/tr11/#Overview) to allow for [`line-too-long`] violations. By default,
/// this is set to the value of the global `line-width` option.
///
/// Overriding the global [`line-width`] allows to use a lower limit for Ruff's formatter and warn about
/// extra-long lines that can't be split by the formatter using [`line-too-long`]:
/// Overriding the global [`line-width`](#line-width) allows to use a lower limit for Ruff's formatter and warn about
/// extra-long lines that can't be split by the formatter using the [`line-too-long`](https://docs.astral.sh/ruff/rules/line-too-long/) rule:
///
/// ```toml
/// line-width = 88 # The formatter breaks line's with a width of 88.
Expand All @@ -2279,8 +2279,6 @@ pub struct PycodestyleOptions {
/// max-line-width = 100 # E501 reports lines that exceed the width of 100.
/// ```
///
/// [`line-too-long`].
///
/// See the [`line-too-long`](https://docs.astral.sh/ruff/rules/line-too-long/) rule for more information.
#[option(
default = "null",
Expand Down Expand Up @@ -2311,7 +2309,7 @@ pub struct PycodestyleOptions {
///
/// See the [`doc-line-too-long`](https://docs.astral.sh/ruff/rules/doc-line-too-long/) rule for more information.
#[option(
default = "None",
default = "null",
value_type = "int",
example = r#"
max-doc-length = 88
Expand Down Expand Up @@ -2389,7 +2387,7 @@ pub struct PydocstyleOptions {
/// enabling _additional_ rules on top of a convention is currently
/// unsupported.
#[option(
default = r#"None"#,
default = r#"null"#,
value_type = r#""google" | "numpy" | "pep257""#,
example = r#"
# Use Google-style docstrings.
Expand Down
2 changes: 1 addition & 1 deletion ruff.schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 710f0a3

Please sign in to comment.