Merge pull request #256 from Birdi7/patch-2

fix: renamed_argument decorator error
This commit is contained in:
Alex Root Junior 2020-01-04 17:36:33 +02:00 committed by GitHub
commit facae42bad
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) 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)