diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_generic_class.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_generic_class.rs index 4541665d2774c..4c2de26865bfd 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_generic_class.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_generic_class.rs @@ -65,6 +65,10 @@ use super::{check_type_vars, in_nested_context, DisplayTypeVars, TypeVarReferenc /// [`unused-private-type-var`][PYI018] for a rule to clean up unused /// private type variables. /// +/// This rule will not rename private type variables to remove leading underscores, even though the +/// new type parameters are restricted in scope to their associated class. See +/// [`private-type-parameter`][UP049] for a rule to update these names. +/// /// This rule will correctly handle classes with multiple base classes, as long as the single /// `Generic` base class is at the end of the argument list, as checked by /// [`generic-not-last-base-class`][PYI059]. If a `Generic` base class is @@ -78,6 +82,7 @@ use super::{check_type_vars, in_nested_context, DisplayTypeVars, TypeVarReferenc /// [PYI018]: https://docs.astral.sh/ruff/rules/unused-private-type-var/ /// [PYI059]: https://docs.astral.sh/ruff/rules/generic-not-last-base-class/ /// [UP047]: https://docs.astral.sh/ruff/rules/non-pep695-generic-function/ +/// [UP049]: https://docs.astral.sh/ruff/rules/private-type-parameter/ #[derive(ViolationMetadata)] pub(crate) struct NonPEP695GenericClass { name: String, diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_generic_function.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_generic_function.rs index 58f09c9caa87b..ea6a8a40b4d7f 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_generic_function.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_generic_function.rs @@ -64,6 +64,10 @@ use super::{check_type_vars, in_nested_context, DisplayTypeVars, TypeVarReferenc /// [`unused-private-type-var`][PYI018] for a rule to clean up unused /// private type variables. /// +/// This rule will not rename private type variables to remove leading underscores, even though the +/// new type parameters are restricted in scope to their associated function. See +/// [`private-type-parameter`][UP049] for a rule to update these names. +/// /// This rule only applies to generic functions and does not include generic classes. See /// [`non-pep695-generic-class`][UP046] for the class version. /// @@ -71,6 +75,7 @@ use super::{check_type_vars, in_nested_context, DisplayTypeVars, TypeVarReferenc /// [PEP 696]: https://peps.python.org/pep-0696/ /// [PYI018]: https://docs.astral.sh/ruff/rules/unused-private-type-var/ /// [UP046]: https://docs.astral.sh/ruff/rules/non-pep695-generic-class/ +/// [UP049]: https://docs.astral.sh/ruff/rules/private-type-parameter/ #[derive(ViolationMetadata)] pub(crate) struct NonPEP695GenericFunction { name: String, diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_type_alias.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_type_alias.rs index 4448f0d7d1a39..0762580d073f7 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_type_alias.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_type_alias.rs @@ -57,7 +57,25 @@ use super::{ /// `TypeAliasType` assignments if there are any comments in the replacement range that would be /// deleted. /// +/// ## See also +/// +/// This rule only applies to `TypeAlias`es and `TypeAliasType`s. See +/// [`non-pep695-generic-class`][UP046] and [`non-pep695-generic-function`][UP047] for similar +/// transformations for generic classes and functions. +/// +/// This rule replaces standalone type variables in aliases but doesn't remove the corresponding +/// type variables even if they are unused after the fix. See [`unused-private-type-var`][PYI018] +/// for a rule to clean up unused private type variables. +/// +/// This rule will not rename private type variables to remove leading underscores, even though the +/// new type parameters are restricted in scope to their associated aliases. See +/// [`private-type-parameter`][UP049] for a rule to update these names. +/// /// [PEP 695]: https://peps.python.org/pep-0695/ +/// [PYI018]: https://docs.astral.sh/ruff/rules/unused-private-type-var/ +/// [UP046]: https://docs.astral.sh/ruff/rules/non-pep695-generic-class/ +/// [UP047]: https://docs.astral.sh/ruff/rules/non-pep695-generic-function/ +/// [UP049]: https://docs.astral.sh/ruff/rules/private-type-parameter/ #[derive(ViolationMetadata)] pub(crate) struct NonPEP695TypeAlias { name: String,