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

Remove deprecated extend-ignore and extend-unfixable options #12007

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 3 additions & 38 deletions crates/ruff/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,6 @@ pub struct CheckCommand {
hide_possible_values = true
)]
pub extend_select: Option<Vec<RuleSelector>>,
/// Like --ignore. (Deprecated: You can just use --ignore instead.)
#[arg(
long,
value_delimiter = ',',
value_name = "RULE_CODE",
value_parser = RuleSelectorParser,
help_heading = "Rule selection",
hide = true
)]
pub extend_ignore: Option<Vec<RuleSelector>>,
/// List of mappings from file pattern to code to exclude.
#[arg(long, value_delimiter = ',', help_heading = "Rule selection")]
pub per_file_ignores: Option<Vec<PatternPrefixPair>>,
Expand Down Expand Up @@ -300,16 +290,7 @@ pub struct CheckCommand {
hide_possible_values = true
)]
pub extend_fixable: Option<Vec<RuleSelector>>,
/// Like --unfixable. (Deprecated: You can just use --unfixable instead.)
#[arg(
long,
value_delimiter = ',',
value_name = "RULE_CODE",
value_parser = RuleSelectorParser,
help_heading = "Rule selection",
hide = true
)]
pub extend_unfixable: Option<Vec<RuleSelector>>,

/// Respect file exclusions via `.gitignore` and other standard ignore files.
/// Use `--no-respect-gitignore` to disable.
#[arg(
Expand Down Expand Up @@ -681,10 +662,8 @@ impl CheckCommand {
exclude: self.exclude,
extend_exclude: self.extend_exclude,
extend_fixable: self.extend_fixable,
extend_ignore: self.extend_ignore,
extend_per_file_ignores: self.extend_per_file_ignores,
extend_select: self.extend_select,
extend_unfixable: self.extend_unfixable,
fixable: self.fixable,
ignore: self.ignore,
line_length: self.line_length,
Expand Down Expand Up @@ -1200,9 +1179,7 @@ struct ExplicitConfigOverrides {
exclude: Option<Vec<FilePattern>>,
extend_exclude: Option<Vec<FilePattern>>,
extend_fixable: Option<Vec<RuleSelector>>,
extend_ignore: Option<Vec<RuleSelector>>,
extend_select: Option<Vec<RuleSelector>>,
extend_unfixable: Option<Vec<RuleSelector>>,
fixable: Option<Vec<RuleSelector>>,
ignore: Option<Vec<RuleSelector>>,
line_length: Option<LineLength>,
Expand Down Expand Up @@ -1255,22 +1232,10 @@ impl ConfigurationTransformer for ExplicitConfigOverrides {
}
config.lint.rule_selections.push(RuleSelection {
select: self.select.clone(),
ignore: self
.ignore
.iter()
.cloned()
.chain(self.extend_ignore.iter().cloned())
.flatten()
.collect(),
Comment on lines -1258 to -1264
Copy link
Member Author

@MichaReiser MichaReiser Jun 24, 2024

Choose a reason for hiding this comment

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

This is a bit unfortunate. We never added deprecation warnings to the CLI. I'm inclined to keep and hide the CLI options for now but add a deprecation warning instead.

It also seems that python-lsp-ruff is using the CLI option :(

https://github.com/python-lsp/python-lsp-ruff/blob/34acd6ed6daaaa3f2756a1a1cf1bfc2d76df7d0f/pylsp_ruff/plugin.py#L611-L612

ignore: self.ignore.iter().flatten().cloned().collect(),
extend_select: self.extend_select.clone().unwrap_or_default(),
fixable: self.fixable.clone(),
unfixable: self
.unfixable
.iter()
.cloned()
.chain(self.extend_unfixable.iter().cloned())
.flatten()
.collect(),
unfixable: self.unfixable.iter().flatten().cloned().collect(),
extend_fixable: self.extend_fixable.clone().unwrap_or_default(),
});
if let Some(output_format) = &self.output_format {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
extend = "../../pyproject.toml"
src = ["."]

[lint]
# Enable I001, and re-enable F841, to test extension priority.
extend-select = ["I001", "F841"]
extend-ignore = ["F401"]
ignore = ["F401"]
extend-exclude = ["./docs/concepts/file.py"]
2 changes: 1 addition & 1 deletion crates/ruff_linter/resources/test/project/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ exclude = ["examples/excluded"]

[tool.ruff.lint]
extend-select = ["I001"]
extend-ignore = ["F841"]
ignore = ["F841"]
31 changes: 2 additions & 29 deletions crates/ruff_workspace/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,23 +642,6 @@ pub struct LintConfiguration {

impl LintConfiguration {
fn from_options(options: LintOptions, project_root: &Path) -> Result<Self> {
#[allow(deprecated)]
let ignore = options
.common
.ignore
.into_iter()
.flatten()
.chain(options.common.extend_ignore.into_iter().flatten())
.collect();
#[allow(deprecated)]
let unfixable = options
.common
.unfixable
.into_iter()
.flatten()
.chain(options.common.extend_unfixable.into_iter().flatten())
.collect();

#[allow(deprecated)]
let ignore_init_module_imports = {
if options.common.ignore_init_module_imports.is_some() {
Expand All @@ -681,10 +664,10 @@ impl LintConfiguration {

rule_selections: vec![RuleSelection {
select: options.common.select,
ignore,
ignore: options.common.ignore.into_iter().flatten().collect(),
extend_select: options.common.extend_select.unwrap_or_default(),
fixable: options.common.fixable,
unfixable,
unfixable: options.common.unfixable.into_iter().flatten().collect(),
extend_fixable: options.common.extend_fixable.unwrap_or_default(),
}],
extend_safe_fixes: options.common.extend_safe_fixes.unwrap_or_default(),
Expand Down Expand Up @@ -1285,11 +1268,6 @@ fn warn_about_deprecated_top_level_lint_options(
used_options.push("dummy-variable-rgx");
}

#[allow(deprecated)]
if top_level_options.extend_ignore.is_some() {
used_options.push("extend-ignore");
}

if top_level_options.extend_select.is_some() {
used_options.push("extend-select");
}
Expand All @@ -1298,11 +1276,6 @@ fn warn_about_deprecated_top_level_lint_options(
used_options.push("extend-fixable");
}

#[allow(deprecated)]
if top_level_options.extend_unfixable.is_some() {
used_options.push("extend-unfixable");
}

if top_level_options.external.is_some() {
used_options.push("external");
}
Expand Down
22 changes: 0 additions & 22 deletions crates/ruff_workspace/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,21 +574,6 @@ pub struct LintCommonOptions {
)]
pub dummy_variable_rgx: Option<String>,

/// A list of rule codes or prefixes to ignore, in addition to those
/// specified by `ignore`.
#[option(
default = "[]",
value_type = "list[RuleSelector]",
example = r#"
# Skip unused variable rules (`F841`).
extend-ignore = ["F841"]
"#
)]
#[deprecated(
note = "The `extend-ignore` option is now interchangeable with `ignore`. Please update your configuration to use the `ignore` option instead."
)]
pub extend_ignore: Option<Vec<RuleSelector>>,

/// A list of rule codes or prefixes to enable, in addition to those
/// specified by `select`.
#[option(
Expand All @@ -613,13 +598,6 @@ pub struct LintCommonOptions {
)]
pub extend_fixable: Option<Vec<RuleSelector>>,

/// A list of rule codes or prefixes to consider non-auto-fixable, in addition to those
/// specified by `unfixable`.
#[deprecated(
note = "The `extend-unfixable` option is now interchangeable with `unfixable`. Please update your configuration to use the `unfixable` option instead."
)]
pub extend_unfixable: Option<Vec<RuleSelector>>,

/// A list of rule codes or prefixes that are unsupported by Ruff, but should be
/// preserved when (e.g.) validating `# noqa` directives. Useful for
/// retaining `# noqa` directives that cover plugins not yet implemented
Expand Down
2 changes: 1 addition & 1 deletion docs/linter.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ You may use prefixes to select rules as well, e.g., `F` can be used to promote f

To limit the set of rules that Ruff should fix, use the [`lint.fixable`](settings.md#lint_fixable) and
[`lint.unfixable`](settings.md#lint_unfixable) settings, along with their [`lint.extend-fixable`](settings.md#lint_extend-fixable)
and [`lint.extend-unfixable`](settings.md#lint_extend-unfixable) variants.
and [`lint.unfixable`](settings.md#lint_unfixable) variants.

For example, the following configuration would enable fixes for all rules except
[`unused-imports`](rules/unused-import.md) (`F401`):
Expand Down
44 changes: 0 additions & 44 deletions ruff.schema.json

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

Loading