mirror of https://github.com/astral-sh/ruff
WIP: Rename rule selector from nursery to preview
This commit is contained in:
parent
6761f33600
commit
dd4bf76adf
|
|
@ -14,8 +14,8 @@ use crate::rule_redirects::get_redirect;
|
||||||
pub enum RuleSelector {
|
pub enum RuleSelector {
|
||||||
/// Select all stable rules.
|
/// Select all stable rules.
|
||||||
All,
|
All,
|
||||||
/// Legacy category to select all preview rules, previously known as the nursery
|
/// Category to select all preview rules, previously known as the nursery
|
||||||
Nursery,
|
Preview,
|
||||||
/// Legacy category to select both the `mccabe` and `flake8-comprehensions` linters
|
/// Legacy category to select both the `mccabe` and `flake8-comprehensions` linters
|
||||||
/// via a single selector.
|
/// via a single selector.
|
||||||
C,
|
C,
|
||||||
|
|
@ -43,7 +43,9 @@ impl FromStr for RuleSelector {
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
match s {
|
match s {
|
||||||
"ALL" => Ok(Self::All),
|
"ALL" => Ok(Self::All),
|
||||||
"NURSERY" => Ok(Self::Nursery),
|
// Legacy support for selecting preview rules as "nursery"
|
||||||
|
"NURSERY" => Ok(Self::Preview),
|
||||||
|
"PREVIEW" => Ok(Self::Preview),
|
||||||
"C" => Ok(Self::C),
|
"C" => Ok(Self::C),
|
||||||
"T" => Ok(Self::T),
|
"T" => Ok(Self::T),
|
||||||
_ => {
|
_ => {
|
||||||
|
|
@ -81,7 +83,7 @@ impl RuleSelector {
|
||||||
pub fn prefix_and_code(&self) -> (&'static str, &'static str) {
|
pub fn prefix_and_code(&self) -> (&'static str, &'static str) {
|
||||||
match self {
|
match self {
|
||||||
RuleSelector::All => ("", "ALL"),
|
RuleSelector::All => ("", "ALL"),
|
||||||
RuleSelector::Nursery => ("", "NURSERY"),
|
RuleSelector::Preview => ("", "PREVIEW"),
|
||||||
RuleSelector::C => ("", "C"),
|
RuleSelector::C => ("", "C"),
|
||||||
RuleSelector::T => ("", "T"),
|
RuleSelector::T => ("", "T"),
|
||||||
RuleSelector::Prefix { prefix, .. } => {
|
RuleSelector::Prefix { prefix, .. } => {
|
||||||
|
|
@ -151,7 +153,7 @@ impl IntoIterator for &RuleSelector {
|
||||||
fn into_iter(self) -> Self::IntoIter {
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
match self {
|
match self {
|
||||||
RuleSelector::All => RuleSelectorIter::All(Rule::iter()),
|
RuleSelector::All => RuleSelectorIter::All(Rule::iter()),
|
||||||
RuleSelector::Nursery => {
|
RuleSelector::Preview => {
|
||||||
RuleSelectorIter::Nursery(Rule::iter().filter(Rule::is_preview))
|
RuleSelectorIter::Nursery(Rule::iter().filter(Rule::is_preview))
|
||||||
}
|
}
|
||||||
RuleSelector::C => RuleSelectorIter::Chain(
|
RuleSelector::C => RuleSelectorIter::Chain(
|
||||||
|
|
@ -264,7 +266,7 @@ impl RuleSelector {
|
||||||
pub fn specificity(&self) -> Specificity {
|
pub fn specificity(&self) -> Specificity {
|
||||||
match self {
|
match self {
|
||||||
RuleSelector::All => Specificity::All,
|
RuleSelector::All => Specificity::All,
|
||||||
RuleSelector::Nursery => Specificity::All,
|
RuleSelector::Preview => Specificity::All,
|
||||||
RuleSelector::T => Specificity::LinterGroup,
|
RuleSelector::T => Specificity::LinterGroup,
|
||||||
RuleSelector::C => Specificity::LinterGroup,
|
RuleSelector::C => Specificity::LinterGroup,
|
||||||
RuleSelector::Linter(..) => Specificity::Linter,
|
RuleSelector::Linter(..) => Specificity::Linter,
|
||||||
|
|
|
||||||
|
|
@ -445,7 +445,7 @@ impl Configuration {
|
||||||
// The fixable set keeps track of which rules are fixable.
|
// The fixable set keeps track of which rules are fixable.
|
||||||
let mut fixable_set: RuleSet = RuleSelector::All
|
let mut fixable_set: RuleSet = RuleSelector::All
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(&RuleSelector::Nursery)
|
.chain(&RuleSelector::Preview)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// Ignores normally only subtract from the current set of selected
|
// Ignores normally only subtract from the current set of selected
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue