This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.


aiogram.utils.deprecated.renamed_argument(old_name: str, new_name: str, until_version: str, stacklevel: int = 3)[source]

A meta-decorator to mark an argument as deprecated.

@renamed_argument("chat", "chat_id", "3.0")  # stacklevel=3 by default
@renamed_argument("user", "user_id", "3.0", stacklevel=4)
def some_function(user_id, chat_id=None):
    print(f"user_id={user_id}, chat_id={chat_id}")

some_function(user=123)  #  prints 'user_id=123, chat_id=None' with warning
some_function(123)  #  prints 'user_id=123, chat_id=None' without warning
some_function(user_id=123)  #  prints 'user_id=123, chat_id=None' without warning
  • old_name

  • new_name

  • until_version – the version in which the argument is scheduled to be removed

  • stacklevel – leave it to default if it’s the first decorator used.

Increment with any new decorator used. :return: decorator