astral-sh/ruff · error

Selection of deprecated rules is not allowed when preview…

Error message

Selection of deprecated rules is not allowed when preview is enabled. Remove selection of:

What it means

An anyhow error listing all deprecated rules selected in the configuration while preview mode is enabled. It is the multi-rule variant of the single deprecated-rule error and aborts configuration loading until the listed selections are removed.

Solutions

  1. Remove every deprecated rule listed in the message from the configuration
  2. Keep preview mode off until the deprecated rules are dropped
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/ruff_workspace/src/configuration.rs:1206 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of astral-sh/ruff@26f38c119c (2026-09-05). Data as JSON: /api/errors/e6db55516dfdd13a. Report an issue: GitHub.

Appendix: source

Thrown at crates/ruff_workspace/src/configuration.rs:1206

                    let (prefix, code) = selection.prefix_and_code();
                    return Err(anyhow!(
                        "Selection of deprecated rule `{prefix}{code}` is not allowed when \
                         preview is enabled."
                    ));
                }
                [..] => {
                    let mut message = "\
                        Selection of deprecated rules is not allowed \
                            when preview is enabled. Remove selection of:"
                        .to_string();
                    for selection in deprecated_selectors {
                        let (prefix, code) = selection.prefix_and_code();
                        message.push_str("\n\t- ");
                        message.push_str(prefix);
                        message.push_str(code);
                    }
                    message.push('\n');
                    return Err(anyhow!(message));
                }
            }
        }

        for selection in ignored_preview_selectors.iter().sorted() {
            let (prefix, code) = selection.prefix_and_code();
            warn_user_once_by_message!(
                "Selection `{prefix}{code}` has no effect because preview is not enabled.",
            );
        }

        let mut rules = RuleTable::empty();

        for rule in select_set {
            let fix = fixable_set.contains(rule);
            rules.enable(rule, fix);
        }

View on GitHub (pinned to 26f38c119c)