mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 21:05:08 +00:00
Remove deprecated configuration '--show-source` (#9814)
Co-authored-by: Micha Reiser <micha@reiser.io> Fixes parts of https://github.com/astral-sh/ruff/issues/7650
This commit is contained in:
parent
a4688aebe9
commit
b24e4473c5
10 changed files with 76 additions and 263 deletions
|
@ -27,8 +27,8 @@ use ruff_linter::rules::pycodestyle;
|
|||
use ruff_linter::settings::fix_safety_table::FixSafetyTable;
|
||||
use ruff_linter::settings::rule_table::RuleTable;
|
||||
use ruff_linter::settings::types::{
|
||||
CompiledPerFileIgnoreList, ExtensionMapping, FilePattern, FilePatternSet, PerFileIgnore,
|
||||
PreviewMode, PythonVersion, RequiredVersion, SerializationFormat, UnsafeFixes,
|
||||
CompiledPerFileIgnoreList, ExtensionMapping, FilePattern, FilePatternSet, OutputFormat,
|
||||
PerFileIgnore, PreviewMode, PythonVersion, RequiredVersion, UnsafeFixes,
|
||||
};
|
||||
use ruff_linter::settings::{LinterSettings, DEFAULT_SELECTORS, DUMMY_VARIABLE_RGX, TASK_TAGS};
|
||||
use ruff_linter::{
|
||||
|
@ -116,7 +116,7 @@ pub struct Configuration {
|
|||
pub fix: Option<bool>,
|
||||
pub fix_only: Option<bool>,
|
||||
pub unsafe_fixes: Option<UnsafeFixes>,
|
||||
pub output_format: Option<SerializationFormat>,
|
||||
pub output_format: Option<OutputFormat>,
|
||||
pub preview: Option<PreviewMode>,
|
||||
pub required_version: Option<RequiredVersion>,
|
||||
pub extension: Option<ExtensionMapping>,
|
||||
|
@ -222,7 +222,7 @@ impl Configuration {
|
|||
unsafe_fixes: self.unsafe_fixes.unwrap_or_default(),
|
||||
output_format: self
|
||||
.output_format
|
||||
.unwrap_or_else(|| SerializationFormat::default(global_preview.is_enabled())),
|
||||
.unwrap_or_else(|| OutputFormat::default(global_preview.is_enabled())),
|
||||
show_fixes: self.show_fixes.unwrap_or(false),
|
||||
|
||||
file_resolver: FileResolverSettings {
|
||||
|
@ -429,30 +429,16 @@ impl Configuration {
|
|||
options.indent_width.or(options.tab_size)
|
||||
};
|
||||
|
||||
#[allow(deprecated)]
|
||||
let output_format = {
|
||||
if options.show_source.is_some() {
|
||||
warn_user_once!(
|
||||
r#"The `show-source` option has been deprecated in favor of `output-format`'s "full" and "concise" variants. Please update your configuration to use `output-format = <full|concise>` instead."#
|
||||
);
|
||||
}
|
||||
|
||||
options
|
||||
.output_format
|
||||
.map(|format| match format {
|
||||
SerializationFormat::Text => {
|
||||
warn_user_once!(r#"Setting `output_format` to "text" is deprecated. Use "full" or "concise" instead. "text" will be treated as "{}"."#, SerializationFormat::default(options.preview.unwrap_or_default()));
|
||||
SerializationFormat::default(options.preview.unwrap_or_default())
|
||||
OutputFormat::Text => {
|
||||
warn_user_once!(r#"Setting `output_format` to "text" is deprecated. Use "full" or "concise" instead. "text" will be treated as "{}"."#, OutputFormat::default(options.preview.unwrap_or_default()));
|
||||
OutputFormat::default(options.preview.unwrap_or_default())
|
||||
},
|
||||
other => other
|
||||
})
|
||||
.or(options.show_source.map(|show_source| {
|
||||
if show_source {
|
||||
SerializationFormat::Full
|
||||
} else {
|
||||
SerializationFormat::Concise
|
||||
}
|
||||
}))
|
||||
};
|
||||
|
||||
Ok(Self {
|
||||
|
|
|
@ -24,7 +24,7 @@ use ruff_linter::rules::{
|
|||
pycodestyle, pydocstyle, pyflakes, pylint, pyupgrade,
|
||||
};
|
||||
use ruff_linter::settings::types::{
|
||||
IdentifierPattern, PythonVersion, RequiredVersion, SerializationFormat,
|
||||
IdentifierPattern, OutputFormat, PythonVersion, RequiredVersion,
|
||||
};
|
||||
use ruff_linter::{warn_user_once, RuleSelector};
|
||||
use ruff_macros::{CombineOptions, OptionsMetadata};
|
||||
|
@ -86,7 +86,7 @@ pub struct Options {
|
|||
output-format = "grouped"
|
||||
"#
|
||||
)]
|
||||
pub output_format: Option<SerializationFormat>,
|
||||
pub output_format: Option<OutputFormat>,
|
||||
|
||||
/// Enable fix behavior by-default when running `ruff` (overridden
|
||||
/// by the `--fix` and `--no-fix` command-line flags).
|
||||
|
@ -108,21 +108,6 @@ pub struct Options {
|
|||
#[option(default = "false", value_type = "bool", example = "fix-only = true")]
|
||||
pub fix_only: Option<bool>,
|
||||
|
||||
/// Whether to show source code snippets when reporting lint violations
|
||||
/// (overridden by the `--show-source` command-line flag).
|
||||
#[option(
|
||||
default = "false",
|
||||
value_type = "bool",
|
||||
example = r#"
|
||||
# By default, always show source code snippets.
|
||||
show-source = true
|
||||
"#
|
||||
)]
|
||||
#[deprecated(
|
||||
note = "`show-source` is deprecated and is now part of `output-format` in the form of `full` or `concise` options. Please update your configuration."
|
||||
)]
|
||||
pub show_source: Option<bool>,
|
||||
|
||||
/// Whether to show an enumeration of all fixed lint violations
|
||||
/// (overridden by the `--show-fixes` command-line flag).
|
||||
#[option(
|
||||
|
|
|
@ -3,7 +3,7 @@ use ruff_cache::cache_dir;
|
|||
use ruff_formatter::{FormatOptions, IndentStyle, IndentWidth, LineWidth};
|
||||
use ruff_linter::display_settings;
|
||||
use ruff_linter::settings::types::{
|
||||
ExtensionMapping, FilePattern, FilePatternSet, SerializationFormat, UnsafeFixes,
|
||||
ExtensionMapping, FilePattern, FilePatternSet, OutputFormat, UnsafeFixes,
|
||||
};
|
||||
use ruff_linter::settings::LinterSettings;
|
||||
use ruff_macros::CacheKey;
|
||||
|
@ -28,7 +28,7 @@ pub struct Settings {
|
|||
#[cache_key(ignore)]
|
||||
pub unsafe_fixes: UnsafeFixes,
|
||||
#[cache_key(ignore)]
|
||||
pub output_format: SerializationFormat,
|
||||
pub output_format: OutputFormat,
|
||||
#[cache_key(ignore)]
|
||||
pub show_fixes: bool,
|
||||
|
||||
|
@ -44,7 +44,7 @@ impl Default for Settings {
|
|||
cache_dir: cache_dir(project_root),
|
||||
fix: false,
|
||||
fix_only: false,
|
||||
output_format: SerializationFormat::default(false),
|
||||
output_format: OutputFormat::default(false),
|
||||
show_fixes: false,
|
||||
unsafe_fixes: UnsafeFixes::default(),
|
||||
linter: LinterSettings::new(project_root),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue