Skip to main content

warn_about_renamed_method

This class acts as a decorator to facilitate the deprecation of renamed methods within a class. It issues a specified deprecation warning whenever the old method name is invoked, directing users to the new method name while maintaining the original functionality. This utility helps manage API transitions by providing clear feedback to developers during the migration process.

Attributes

AttributeTypeDescription
class_namestringThe name of the class containing the deprecated method, used to construct the warning message.
old_method_namestringThe name of the original method that is being deprecated.
new_method_namestringThe name of the replacement method that users should migrate to.
deprecation_warning[Warning](../../../../../core/checks/messages/warning.md?sid=django_core_checks_messages_warning)The specific Warning class type to be issued when the old method is called.

Constructor

Signature

def warn_about_renamed_method(
class_name: string,
old_method_name: string,
new_method_name: string,
deprecation_warning: [Warning](../../../../../core/checks/messages/warning.md?sid=django_core_checks_messages_warning)
)

Parameters

NameTypeDescription
class_namestringThe name of the class containing the renamed method.
old_method_namestringThe original name of the method that is now deprecated.
new_method_namestringThe new name of the method that should be used instead.
deprecation_warning[Warning](../../../../../core/checks/messages/warning.md?sid=django_core_checks_messages_warning)The specific warning class to be issued (e.g., DeprecationWarning).

Signature

def warn_about_renamed_method(
class_name: string,
old_method_name: string,
new_method_name: string,
deprecation_warning: [Warning](../../../../../core/checks/messages/warning.md?sid=django_core_checks_messages_warning)
)

Parameters

NameTypeDescription
class_namestringThe name of the class containing the renamed method to be included in the warning message.
old_method_namestringThe name of the deprecated method that is being replaced.
new_method_namestringThe name of the current method that callers should use instead of the deprecated version.
deprecation_warning[Warning](../../../../../core/checks/messages/warning.md?sid=django_core_checks_messages_warning)The specific Warning class type to be issued when the decorated method is called.