mirror of
https://github.com/astral-sh/ruff
synced 2026-01-21 05:20:49 -05:00
refactor: Move resolve_select to converter module
The function is only used there and is not plugin-specific since it also specifies the default rule selectors (F, E, W).
This commit is contained in:
committed by
Charlie Marsh
parent
3de2a57416
commit
f5ddec0fb3
@@ -76,7 +76,7 @@ pub fn convert(
|
||||
.as_ref()
|
||||
.map(|value| BTreeSet::from_iter(parser::parse_prefix_codes(value)))
|
||||
})
|
||||
.unwrap_or_else(|| plugin::resolve_select(&plugins));
|
||||
.unwrap_or_else(|| resolve_select(&plugins));
|
||||
let mut ignore = flake8
|
||||
.get("ignore")
|
||||
.and_then(|value| {
|
||||
@@ -406,6 +406,14 @@ pub fn convert(
|
||||
Ok(Pyproject::new(options))
|
||||
}
|
||||
|
||||
/// Resolve the set of enabled `RuleSelector` values for the given
|
||||
/// plugins.
|
||||
fn resolve_select(plugins: &[Plugin]) -> BTreeSet<RuleSelector> {
|
||||
let mut select = BTreeSet::from([RuleSelector::F, RuleSelector::E, RuleSelector::W]);
|
||||
select.extend(plugins.iter().map(Plugin::selector));
|
||||
select
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -286,14 +286,6 @@ pub fn infer_plugins_from_codes(selectors: &BTreeSet<RuleSelector>) -> Vec<Plugi
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Resolve the set of enabled `RuleSelector` values for the given
|
||||
/// plugins.
|
||||
pub fn resolve_select(plugins: &[Plugin]) -> BTreeSet<RuleSelector> {
|
||||
let mut select = BTreeSet::from([RuleSelector::F, RuleSelector::E, RuleSelector::W]);
|
||||
select.extend(plugins.iter().map(Plugin::selector));
|
||||
select
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::collections::HashMap;
|
||||
|
||||
Reference in New Issue
Block a user