mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 04:19:18 +00:00
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:
parent
c86e14d1d4
commit
a0ef087e73
10 changed files with 279 additions and 21 deletions
|
@ -26,9 +26,9 @@ pub(crate) fn main(args: &Args) -> Result<()> {
|
|||
for rule in Rule::iter() {
|
||||
if let Some(explanation) = rule.explanation() {
|
||||
let mut output = String::new();
|
||||
|
||||
output.push_str(&format!("# {} ({})", rule.as_ref(), rule.noqa_code()));
|
||||
output.push('\n');
|
||||
output.push('\n');
|
||||
|
||||
let (linter, _) = Linter::parse_code(&rule.noqa_code().to_string()).unwrap();
|
||||
if linter.url().is_some() {
|
||||
|
@ -37,6 +37,14 @@ pub(crate) fn main(args: &Args) -> Result<()> {
|
|||
output.push('\n');
|
||||
}
|
||||
|
||||
if rule.is_deprecated() {
|
||||
output.push_str(
|
||||
r"**Warning: This rule is deprecated and will be removed in a future release.**",
|
||||
);
|
||||
output.push('\n');
|
||||
output.push('\n');
|
||||
}
|
||||
|
||||
let fix_availability = rule.fixable();
|
||||
if matches!(
|
||||
fix_availability,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue