mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Merge pull request #256 from Birdi7/patch-2
fix: renamed_argument decorator error
This commit is contained in:
commit
facae42bad
1 changed files with 5 additions and 1 deletions
|
|
@ -102,14 +102,18 @@ def renamed_argument(old_name: str, new_name: str, until_version: str, stackleve
|
||||||
is_coroutine = asyncio.iscoroutinefunction(func)
|
is_coroutine = asyncio.iscoroutinefunction(func)
|
||||||
|
|
||||||
def _handling(kwargs):
|
def _handling(kwargs):
|
||||||
|
"""
|
||||||
|
Returns updated version of kwargs.
|
||||||
|
"""
|
||||||
routine_type = 'coroutine' if is_coroutine else 'function'
|
routine_type = 'coroutine' if is_coroutine else 'function'
|
||||||
if old_name in kwargs:
|
if old_name in kwargs:
|
||||||
warn_deprecated(f"In {routine_type} '{func.__name__}' argument '{old_name}' "
|
warn_deprecated(f"In {routine_type} '{func.__name__}' argument '{old_name}' "
|
||||||
f"is renamed to '{new_name}' "
|
f"is renamed to '{new_name}' "
|
||||||
f"and will be removed in aiogram {until_version}",
|
f"and will be removed in aiogram {until_version}",
|
||||||
stacklevel=stacklevel)
|
stacklevel=stacklevel)
|
||||||
|
kwargs = kwargs.copy()
|
||||||
kwargs.update({new_name: kwargs.pop(old_name)})
|
kwargs.update({new_name: kwargs.pop(old_name)})
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
if is_coroutine:
|
if is_coroutine:
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue