fix: renamed_argument decorator error

Also, I removed hidden mutation of input in _handling function
This commit is contained in:
Egor 2020-01-04 20:17:22 +05:00 committed by GitHub
parent 3783e7052a
commit b436cf8e27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -102,14 +102,18 @@ def renamed_argument(old_name: str, new_name: str, until_version: str, stackleve
is_coroutine = asyncio.iscoroutinefunction(func)
def _handling(kwargs):
"""
Returns updated version of kwargs.
"""
routine_type = 'coroutine' if is_coroutine else 'function'
if old_name in kwargs:
warn_deprecated(f"In {routine_type} '{func.__name__}' argument '{old_name}' "
f"is renamed to '{new_name}' "
f"and will be removed in aiogram {until_version}",
stacklevel=stacklevel)
kwargs = kwargs.copy()
kwargs.update({new_name: kwargs.pop(old_name)})
return kwargs
return kwargs
if is_coroutine:
@functools.wraps(func)