From 33c8c7569d7188abf62fd70f01b4e65783debcc9 Mon Sep 17 00:00:00 2001 From: Brent Westbrook <36778786+ntBre@users.noreply.github.com> Date: Thu, 12 Jun 2025 10:26:15 -0400 Subject: [PATCH] [`pandas-vet`] Deprecate `pandas-df-variable-name` (`PD901`) (#18618) Summary -- Deprecates PD901 as part of #7710. I don't feel particularly strongly about this one, though I have certainly used `df` as a dataframe name in the past, just going through the open issues in the 0.12 milestone. Test Plan -- N/a --- crates/ruff_linter/src/codes.rs | 2 +- .../src/rules/pandas_vet/rules/assignment_to_df.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/ruff_linter/src/codes.rs b/crates/ruff_linter/src/codes.rs index d2de55efba..732c2aee11 100644 --- a/crates/ruff_linter/src/codes.rs +++ b/crates/ruff_linter/src/codes.rs @@ -752,7 +752,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (PandasVet, "013") => (RuleGroup::Stable, rules::pandas_vet::rules::PandasUseOfDotStack), (PandasVet, "015") => (RuleGroup::Stable, rules::pandas_vet::rules::PandasUseOfPdMerge), (PandasVet, "101") => (RuleGroup::Stable, rules::pandas_vet::rules::PandasNuniqueConstantSeriesCheck), - (PandasVet, "901") => (RuleGroup::Stable, rules::pandas_vet::rules::PandasDfVariableName), + (PandasVet, "901") => (RuleGroup::Deprecated, rules::pandas_vet::rules::PandasDfVariableName), // flake8-errmsg (Flake8ErrMsg, "101") => (RuleGroup::Stable, rules::flake8_errmsg::rules::RawStringInException), diff --git a/crates/ruff_linter/src/rules/pandas_vet/rules/assignment_to_df.rs b/crates/ruff_linter/src/rules/pandas_vet/rules/assignment_to_df.rs index b24fd8f0bb..3c0617b708 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/rules/assignment_to_df.rs +++ b/crates/ruff_linter/src/rules/pandas_vet/rules/assignment_to_df.rs @@ -4,6 +4,10 @@ use ruff_text_size::Ranged; use crate::{Violation, checkers::ast::Checker}; +/// ## Deprecated +/// +/// This rule has been deprecated as it's highly opinionated and overly strict in most cases. +/// /// ## What it does /// Checks for assignments to the variable `df`. ///