mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 02:12:22 +00:00
Add hidden --preview
/ --no-preview
options to ruff check
(#7009)
Per discussion at https://github.com/astral-sh/ruff/discussions/6998 <!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary <!-- What's the purpose of the change? What does it do, and why? --> Adds a `--preview` and `--no-preview` option to the CLI for `ruff check` and corresponding settings. The CLI options are hidden for now. Available in the settings as `preview = true` or `preview = false`. Does not include environment variable configuration, although we may add it in the future. ## Test Plan <!-- How was it tested? --> `cargo build` Future work will build on this setting, such as toggling the mode during a test.
This commit is contained in:
parent
f4ba0ea144
commit
96a9717c1a
8 changed files with 57 additions and 3 deletions
|
@ -23,7 +23,8 @@ use ruff::registry::{Rule, RuleSet, INCOMPATIBLE_CODES};
|
|||
use ruff::rule_selector::Specificity;
|
||||
use ruff::settings::rule_table::RuleTable;
|
||||
use ruff::settings::types::{
|
||||
FilePattern, FilePatternSet, PerFileIgnore, PythonVersion, SerializationFormat, Version,
|
||||
FilePattern, FilePatternSet, PerFileIgnore, PreviewMode, PythonVersion, SerializationFormat,
|
||||
Version,
|
||||
};
|
||||
use ruff::settings::{defaults, resolve_per_file_ignores, AllSettings, CliSettings, Settings};
|
||||
use ruff::{fs, warn_user_once_by_id, RuleSelector, RUFF_PKG_VERSION};
|
||||
|
@ -67,6 +68,7 @@ pub struct Configuration {
|
|||
pub line_length: Option<LineLength>,
|
||||
pub logger_objects: Option<Vec<String>>,
|
||||
pub namespace_packages: Option<Vec<PathBuf>>,
|
||||
pub preview: Option<PreviewMode>,
|
||||
pub required_version: Option<Version>,
|
||||
pub respect_gitignore: Option<bool>,
|
||||
pub show_fixes: Option<bool>,
|
||||
|
@ -174,6 +176,7 @@ impl Configuration {
|
|||
.collect()
|
||||
}),
|
||||
logger_objects: self.logger_objects.unwrap_or_default(),
|
||||
preview: self.preview.unwrap_or_default(),
|
||||
typing_modules: self.typing_modules.unwrap_or_default(),
|
||||
// Plugins
|
||||
flake8_annotations: self
|
||||
|
@ -387,6 +390,7 @@ impl Configuration {
|
|||
.namespace_packages
|
||||
.map(|namespace_package| resolve_src(&namespace_package, project_root))
|
||||
.transpose()?,
|
||||
preview: options.preview.map(PreviewMode::from),
|
||||
per_file_ignores: options.per_file_ignores.map(|per_file_ignores| {
|
||||
per_file_ignores
|
||||
.into_iter()
|
||||
|
@ -676,6 +680,7 @@ impl Configuration {
|
|||
show_fixes: self.show_fixes.or(config.show_fixes),
|
||||
src: self.src.or(config.src),
|
||||
target_version: self.target_version.or(config.target_version),
|
||||
preview: self.preview.or(config.preview),
|
||||
task_tags: self.task_tags.or(config.task_tags),
|
||||
typing_modules: self.typing_modules.or(config.typing_modules),
|
||||
// Plugins
|
||||
|
|
|
@ -482,6 +482,17 @@ pub struct Options {
|
|||
/// field (e.g., `requires-python = ">=3.8"`). If Ruff is configured via
|
||||
/// `ruff.toml` or `.ruff.toml`, no such inference will be performed.
|
||||
pub target_version: Option<PythonVersion>,
|
||||
#[option(
|
||||
default = "false",
|
||||
value_type = "bool",
|
||||
example = r#"
|
||||
# Enable preview features
|
||||
preview = true
|
||||
"#
|
||||
)]
|
||||
/// Whether to enable preview mode. When preview mode is enabled, Ruff will
|
||||
/// use unstable rules and fixes.
|
||||
pub preview: Option<bool>,
|
||||
#[option(
|
||||
default = r#"["TODO", "FIXME", "XXX"]"#,
|
||||
value_type = "list[str]",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue