Skip to content

Commit 666f01d

Browse files
committed
Add deprecation warning for 'async' parameter
1 parent 1c4499e commit 666f01d

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

cloudbot/plugin.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
import logging
66
import os
77
import re
8+
import warnings
89
from collections import defaultdict
910
from operator import attrgetter
1011
from itertools import chain
1112

1213
import sqlalchemy
14+
import sys
1315

1416
from cloudbot.event import Event
1517
from cloudbot.hook import Priority, Action
@@ -644,6 +646,13 @@ def __init__(self, _type, plugin, func_hook):
644646

645647
# don't process args starting with "_"
646648
self.required_args = [arg for arg in sig.parameters.keys() if not arg.startswith('_')]
649+
if sys.version_info < (3, 7, 0):
650+
if "async" in self.required_args:
651+
logger.warning("Use of deprecated function 'async' in %s", self.description)
652+
warnings.warn(
653+
"event.async() is deprecated, use event.async_call() instead.",
654+
DeprecationWarning, stacklevel=2
655+
)
647656

648657
if asyncio.iscoroutine(self.function) or asyncio.iscoroutinefunction(self.function):
649658
self.threaded = False

0 commit comments

Comments
 (0)