As of today, in order to make a decorator compatible with both normal and async functions, you have to write something like this:
def decor(func): if asyncio.iscoroutinefunction(func): async def wrapper(*args, **kwargs): ... await func(*args, **kwargs) ... else: def wrapper(*args, **kwargs): ... func(*args, **kwargs) ... return wrapper This is an unnecessary repetition. It would be cleaner to be able to write it differently, as such: def decor(func): async? def wrapper(*args, **kwargs): ... await? func(*args, **kwargs) ... return wrapper _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/CTTKN5F5UK2PUILSKEK6HAYEXZPQN5CM/ Code of Conduct: http://python.org/psf/codeofconduct/