mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 10:22:24 +00:00
Rename format
option to output-format
(#7514)
This commit is contained in:
parent
0a167dd20b
commit
bb4f7c681a
10 changed files with 83 additions and 44 deletions
|
@ -66,7 +66,7 @@ pub struct Configuration {
|
|||
pub fix: Option<bool>,
|
||||
pub fix_only: Option<bool>,
|
||||
pub force_exclude: Option<bool>,
|
||||
pub format: Option<SerializationFormat>,
|
||||
pub output_format: Option<SerializationFormat>,
|
||||
pub ignore_init_module_imports: Option<bool>,
|
||||
pub include: Option<Vec<FilePattern>>,
|
||||
pub line_length: Option<LineLength>,
|
||||
|
@ -119,7 +119,7 @@ impl Configuration {
|
|||
.unwrap_or_else(|| cache_dir(project_root)),
|
||||
fix: self.fix.unwrap_or(false),
|
||||
fix_only: self.fix_only.unwrap_or(false),
|
||||
format: self.format.unwrap_or_default(),
|
||||
output_format: self.output_format.unwrap_or_default(),
|
||||
show_fixes: self.show_fixes.unwrap_or(false),
|
||||
show_source: self.show_source.unwrap_or(false),
|
||||
},
|
||||
|
@ -376,7 +376,7 @@ impl Configuration {
|
|||
external: options.external,
|
||||
fix: options.fix,
|
||||
fix_only: options.fix_only,
|
||||
format: options.format,
|
||||
output_format: options.output_format.or(options.format),
|
||||
force_exclude: options.force_exclude,
|
||||
ignore_init_module_imports: options.ignore_init_module_imports,
|
||||
include: options.include.map(|paths| {
|
||||
|
@ -708,7 +708,7 @@ impl Configuration {
|
|||
external: self.external.or(config.external),
|
||||
fix: self.fix.or(config.fix),
|
||||
fix_only: self.fix_only.or(config.fix_only),
|
||||
format: self.format.or(config.format),
|
||||
output_format: self.output_format.or(config.output_format),
|
||||
force_exclude: self.force_exclude.or(config.force_exclude),
|
||||
include: self.include.or(config.include),
|
||||
ignore_init_module_imports: self
|
||||
|
|
|
@ -236,20 +236,33 @@ pub struct Options {
|
|||
/// A list of rule codes or prefixes to consider autofixable. By default,
|
||||
/// all rules are considered autofixable.
|
||||
pub fixable: Option<Vec<RuleSelector>>,
|
||||
#[option(
|
||||
default = r#""text""#,
|
||||
value_type = r#""text" | "json" | "junit" | "github" | "gitlab" | "pylint" | "azure""#,
|
||||
example = r#"
|
||||
# Group violations by containing file.
|
||||
format = "grouped"
|
||||
"#
|
||||
)]
|
||||
|
||||
/// The style in which violation messages should be formatted: `"text"`
|
||||
/// (default), `"grouped"` (group messages by file), `"json"`
|
||||
/// (machine-readable), `"junit"` (machine-readable XML), `"github"` (GitHub
|
||||
/// Actions annotations), `"gitlab"` (GitLab CI code quality report),
|
||||
/// `"pylint"` (Pylint text format) or `"azure"` (Azure Pipeline logging commands).
|
||||
///
|
||||
/// This option has been **deprecated** in favor of `output-format`
|
||||
/// to avoid ambiguity with Ruff's upcoming formatter.
|
||||
#[cfg_attr(feature = "schemars", schemars(skip))]
|
||||
pub format: Option<SerializationFormat>,
|
||||
|
||||
/// The style in which violation messages should be formatted: `"text"`
|
||||
/// (default), `"grouped"` (group messages by file), `"json"`
|
||||
/// (machine-readable), `"junit"` (machine-readable XML), `"github"` (GitHub
|
||||
/// Actions annotations), `"gitlab"` (GitLab CI code quality report),
|
||||
/// `"pylint"` (Pylint text format) or `"azure"` (Azure Pipeline logging commands).
|
||||
#[option(
|
||||
default = r#""text""#,
|
||||
value_type = r#""text" | "json" | "junit" | "github" | "gitlab" | "pylint" | "azure""#,
|
||||
example = r#"
|
||||
# Group violations by containing file.
|
||||
output-format = "grouped"
|
||||
"#
|
||||
)]
|
||||
pub output_format: Option<SerializationFormat>,
|
||||
|
||||
#[option(
|
||||
default = r#"false"#,
|
||||
value_type = "bool",
|
||||
|
|
|
@ -13,9 +13,9 @@ use log::debug;
|
|||
use path_absolutize::path_dedot;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
|
||||
use ruff_linter::fs;
|
||||
use ruff_linter::packaging::is_package;
|
||||
use ruff_linter::settings::{AllSettings, Settings};
|
||||
use ruff_linter::{fs, warn_user_once};
|
||||
|
||||
use crate::configuration::Configuration;
|
||||
use crate::pyproject;
|
||||
|
@ -221,6 +221,11 @@ fn resolve_configuration(
|
|||
// Resolve the current path.
|
||||
let options = pyproject::load_options(&path)
|
||||
.map_err(|err| anyhow!("Failed to parse `{}`: {}", path.display(), err))?;
|
||||
|
||||
if options.format.is_some() {
|
||||
warn_user_once!("The option `format` has been deprecated to avoid ambiguity with Ruff's upcoming formatter. Use `format-output` instead.");
|
||||
}
|
||||
|
||||
let project_root = relativity.resolve(&path);
|
||||
let configuration = Configuration::from_options(options, &project_root)?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue