Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
15d0346
Emit a warning instead of an error for unknown rule selectors
ntBre Jun 17, 2026
eb4a0eb
copy the test from brent/human-readable-selectors
ntBre Jun 17, 2026
3fbb9b8
o -> safety_override
ntBre Jun 18, 2026
b489608
skip explicit unsafe check
ntBre Jun 18, 2026
3dc170c
test table -> test_case
ntBre Jun 18, 2026
3ce65ef
update valid_toml_but_nonexistent_option_provided_via_config_argument
ntBre Jun 18, 2026
e6bc749
switch to snapshots
ntBre Jun 18, 2026
338f775
preview-gate warning behavior
ntBre Jun 18, 2026
7e4747a
remove unused deserialize impl for PatternPrefixPair
ntBre Jun 18, 2026
5ebc2b5
copy over ValueSourceGuard
ntBre Jun 18, 2026
6e58f65
avoid missing span errors for DeprecatedTopLevelLintOptions
ntBre Jun 18, 2026
19dcadb
add cli constructor, use in tests
ntBre Jun 18, 2026
a2cc9c0
use source and setting to improve error message
ntBre Jun 18, 2026
da85031
don't derive Eq and Hash
ntBre Jun 18, 2026
dcc2d65
add range getter
ntBre Jun 18, 2026
3da50d8
ValueSourceGuard -> RuleSelectorSourceGuard
ntBre Jun 18, 2026
7a87afe
clean up unused snapshots
ntBre Jun 18, 2026
a26853c
add preview cases too
ntBre Jun 18, 2026
e528541
separate tests and inline snapshots
ntBre Jun 22, 2026
e2b0afb
remove private link
ntBre Jun 22, 2026
e90c4ee
Merge branch 'main' into brent/defer-rule-parsing
ntBre Jun 23, 2026
518e4ee
move more information into the error type for better messages
ntBre Jun 23, 2026
276f2f0
test File and Editor source messages
ntBre Jun 23, 2026
1d3b4cb
Merge branch 'main' into HEAD
ntBre Jun 24, 2026
45dab32
expand preview comment
ntBre Jun 24, 2026
bc8cc28
let callers attach setting on error
ntBre Jun 24, 2026
b8cbb44
ruff_ranged_value crate
ntBre Jun 24, 2026
0fc7305
use RangedValue in ruff
ntBre Jun 24, 2026
bbf5576
shear
ntBre Jun 24, 2026
070d7cd
fix optional dep
ntBre Jun 24, 2026
7aa7590
revert Combined for RangedValue dependency
ntBre Jun 24, 2026
fe3d37a
docs
ntBre Jun 24, 2026
420c427
generate readme
ntBre Jun 24, 2026
6f47201
tidy some imports
ntBre Jun 24, 2026
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
25 changes: 25 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ ruff_python_trivia = { version = "0.0.2", path = "crates/ruff_python_trivia" }
ruff_server = { version = "0.0.2", path = "crates/ruff_server" }
ruff_source_file = { version = "0.0.2", path = "crates/ruff_source_file" }
ruff_mdtest = { path = "crates/ruff_mdtest" }
ruff_ranged_value = { version = "0.0.1", path = "crates/ruff_ranged_value" }
ruff_text_size = { version = "0.0.2", path = "crates/ruff_text_size" }
ruff_workspace = { version = "0.0.2", path = "crates/ruff_workspace" }

Expand Down
1 change: 1 addition & 0 deletions crates/ruff/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ruff_options_metadata = { workspace = true, features = ["serde"] }
ruff_python_ast = { workspace = true }
ruff_python_formatter = { workspace = true }
ruff_python_parser = { workspace = true }
ruff_ranged_value = { workspace = true }
ruff_server = { workspace = true }
ruff_source_file = { workspace = true }
ruff_text_size = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions crates/ruff/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The following Ruff workspace members are also available:
- [ruff_python_semantic](https://crates.io/crates/ruff_python_semantic)
- [ruff_python_stdlib](https://crates.io/crates/ruff_python_stdlib)
- [ruff_python_trivia](https://crates.io/crates/ruff_python_trivia)
- [ruff_ranged_value](https://crates.io/crates/ruff_ranged_value)
- [ruff_server](https://crates.io/crates/ruff_server)
- [ruff_source_file](https://crates.io/crates/ruff_source_file)
- [ruff_text_size](https://crates.io/crates/ruff_text_size)
Expand Down
57 changes: 30 additions & 27 deletions crates/ruff/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ use ruff_linter::settings::types::{
ExtensionPair, FilePattern, OutputFormat, PatternPrefixPair, PerFileIgnore, PreviewMode,
PythonVersion, UnsafeFixes,
};
use ruff_linter::{RuleParser, RuleSelector, RuleSelectorParser};
use ruff_linter::{RuleParser, UnresolvedRuleSelector, UnresolvedRuleSelectorParser};
use ruff_options_metadata::{OptionEntry, OptionsMetadata};
use ruff_python_ast as ast;
use ruff_ranged_value::{ValueSource, ValueSourceGuard};
use ruff_source_file::{LineIndex, OneIndexed, PositionEncoding};
use ruff_text_size::TextRange;
use ruff_workspace::configuration::{Configuration, RuleSelection};
Expand Down Expand Up @@ -290,41 +291,41 @@ pub struct CheckCommand {
long,
value_delimiter = ',',
value_name = "RULE_CODE",
value_parser = RuleSelectorParser,
value_parser = UnresolvedRuleSelectorParser,
help_heading = "Rule selection",
hide_possible_values = true
)]
pub select: Option<Vec<RuleSelector>>,
pub select: Option<Vec<UnresolvedRuleSelector>>,
/// Comma-separated list of rule codes to disable.
#[arg(
long,
value_delimiter = ',',
value_name = "RULE_CODE",
value_parser = RuleSelectorParser,
value_parser = UnresolvedRuleSelectorParser,
help_heading = "Rule selection",
hide_possible_values = true
)]
pub ignore: Option<Vec<RuleSelector>>,
pub ignore: Option<Vec<UnresolvedRuleSelector>>,
/// Like --select, but adds additional rule codes on top of those already specified.
#[arg(
long,
value_delimiter = ',',
value_name = "RULE_CODE",
value_parser = RuleSelectorParser,
value_parser = UnresolvedRuleSelectorParser,
help_heading = "Rule selection",
hide_possible_values = true
)]
pub extend_select: Option<Vec<RuleSelector>>,
pub extend_select: Option<Vec<UnresolvedRuleSelector>>,
/// Like --ignore. (Deprecated: You can just use --ignore instead.)
#[arg(
long,
value_delimiter = ',',
value_name = "RULE_CODE",
value_parser = RuleSelectorParser,
value_parser = UnresolvedRuleSelectorParser,
help_heading = "Rule selection",
hide = true
)]
pub extend_ignore: Option<Vec<RuleSelector>>,
pub extend_ignore: Option<Vec<UnresolvedRuleSelector>>,
/// 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 @@ -352,41 +353,41 @@ pub struct CheckCommand {
long,
value_delimiter = ',',
value_name = "RULE_CODE",
value_parser = RuleSelectorParser,
value_parser = UnresolvedRuleSelectorParser,
help_heading = "Rule selection",
hide_possible_values = true
)]
pub fixable: Option<Vec<RuleSelector>>,
pub fixable: Option<Vec<UnresolvedRuleSelector>>,
/// List of rule codes to treat as ineligible for fix. Only applicable when fix itself is enabled (e.g., via `--fix`).
#[arg(
long,
value_delimiter = ',',
value_name = "RULE_CODE",
value_parser = RuleSelectorParser,
value_parser = UnresolvedRuleSelectorParser,
help_heading = "Rule selection",
hide_possible_values = true
)]
pub unfixable: Option<Vec<RuleSelector>>,
pub unfixable: Option<Vec<UnresolvedRuleSelector>>,
/// Like --fixable, but adds additional rule codes on top of those already specified.
#[arg(
long,
value_delimiter = ',',
value_name = "RULE_CODE",
value_parser = RuleSelectorParser,
value_parser = UnresolvedRuleSelectorParser,
help_heading = "Rule selection",
hide_possible_values = true
)]
pub extend_fixable: Option<Vec<RuleSelector>>,
pub extend_fixable: Option<Vec<UnresolvedRuleSelector>>,
/// Like --unfixable. (Deprecated: You can just use --unfixable instead.)
#[arg(
long,
value_delimiter = ',',
value_name = "RULE_CODE",
value_parser = RuleSelectorParser,
value_parser = UnresolvedRuleSelectorParser,
help_heading = "Rule selection",
hide = true
)]
pub extend_unfixable: Option<Vec<RuleSelector>>,
pub extend_unfixable: Option<Vec<UnresolvedRuleSelector>>,
/// Respect file exclusions via `.gitignore` and other standard ignore files.
/// Use `--no-respect-gitignore` to disable.
#[arg(
Expand Down Expand Up @@ -981,6 +982,8 @@ impl TypedValueParser for ConfigArgumentParser {
}
}

let _guard = ValueSourceGuard::new(ValueSource::Cli, false);

let config_parse_error = match toml::Table::from_str(value) {
Ok(table) => match table.try_into::<Options>() {
Ok(option) => {
Expand Down Expand Up @@ -1347,20 +1350,20 @@ struct ExplicitConfigOverrides {
dummy_variable_rgx: Option<Regex>,
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>>,
extend_fixable: Option<Vec<UnresolvedRuleSelector>>,
extend_ignore: Option<Vec<UnresolvedRuleSelector>>,
extend_select: Option<Vec<UnresolvedRuleSelector>>,
extend_unfixable: Option<Vec<UnresolvedRuleSelector>>,
fixable: Option<Vec<UnresolvedRuleSelector>>,
ignore: Option<Vec<UnresolvedRuleSelector>>,
line_length: Option<LineLength>,
per_file_ignores: Option<Vec<PatternPrefixPair>>,
extend_per_file_ignores: Option<Vec<PatternPrefixPair>>,
preview: Option<PreviewMode>,
respect_gitignore: Option<bool>,
select: Option<Vec<RuleSelector>>,
select: Option<Vec<UnresolvedRuleSelector>>,
target_version: Option<ast::PythonVersion>,
unfixable: Option<Vec<RuleSelector>>,
unfixable: Option<Vec<UnresolvedRuleSelector>>,
// TODO(charlie): Captured in pyproject.toml as a default, but not part of `Settings`.
cache_dir: Option<PathBuf>,
fix: Option<bool>,
Expand Down Expand Up @@ -1473,7 +1476,7 @@ impl ConfigurationTransformer for ExplicitConfigOverrides {

/// Convert a list of `PatternPrefixPair` structs to `PerFileIgnore`.
pub fn collect_per_file_ignores(pairs: Vec<PatternPrefixPair>) -> Vec<PerFileIgnore> {
let mut per_file_ignores: FxHashMap<String, Vec<RuleSelector>> = FxHashMap::default();
let mut per_file_ignores: FxHashMap<String, Vec<UnresolvedRuleSelector>> = FxHashMap::default();
for pair in pairs {
per_file_ignores
.entry(pair.pattern)
Expand All @@ -1482,6 +1485,6 @@ pub fn collect_per_file_ignores(pairs: Vec<PatternPrefixPair>) -> Vec<PerFileIgn
}
per_file_ignores
.into_iter()
.map(|(pattern, prefixes)| PerFileIgnore::new(pattern, &prefixes, None))
.map(|(pattern, prefixes)| PerFileIgnore::new(pattern, prefixes, None))
.collect()
}
Loading
Loading