Add rule deprecation infrastructure (#9689)

Adds a new `Deprecated` rule group in addition to `Stable` and
`Preview`.

Deprecated rules:
- Warn on explicit selection without preview
- Error on explicit selection with preview
- Are excluded when selected by prefix with preview

Deprecates `TRY200`, `ANN101`, and `ANN102` as a proof of concept. We
can consider deprecating them separately.
This commit is contained in:
Zanie Blue 2024-01-30 11:38:25 -06:00
parent c86e14d1d4
commit a0ef087e73
10 changed files with 279 additions and 21 deletions

View file

@ -317,10 +317,18 @@ See also https://github.com/astral-sh/ruff/issues/2186.
matches!(self.group(), RuleGroup::Preview)
}
pub fn is_stable(&self) -> bool {
matches!(self.group(), RuleGroup::Stable)
}
#[allow(deprecated)]
pub fn is_nursery(&self) -> bool {
matches!(self.group(), RuleGroup::Nursery)
}
pub fn is_deprecated(&self) -> bool {
matches!(self.group(), RuleGroup::Deprecated)
}
}
impl Linter {