Skip to content

Commit a822ea1

Browse files
authored
Merge pull request #10 from Kyrmasch/master
Fix: inspect.isfunction -> inspect.isroutine
2 parents 96572c7 + 381cedd commit a822ea1

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

mediatr/exceptions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ def raise_if_request_none(request):
1212

1313

1414
def raise_if_handler_is_invalid(handler):
15-
isfunc = inspect.isfunction(handler)
15+
isfunc = inspect.isroutine(handler)
1616

1717
func = None
1818
if isfunc:
1919
func = handler
2020
else:
2121
if hasattr(handler, 'handle'):
22-
if inspect.isfunction(handler.handle):
22+
if inspect.isroutine(handler.handle):
2323
func = handler.handle
2424
elif inspect.ismethod(handler.handle):
2525
func = handler.__class__.handle
@@ -33,9 +33,9 @@ def raise_if_handler_is_invalid(handler):
3333

3434

3535
def raise_if_behavior_is_invalid(behavior):
36-
isfunc = inspect.isfunction(behavior)
36+
isfunc = inspect.isroutine(behavior)
3737
func = behavior if isfunc else (behavior.handle if hasattr(behavior, 'handle') else None)
38-
if not func or not inspect.isfunction(func):
38+
if not func or not inspect.isroutine(func):
3939
raise InvalidHandlerError(func)
4040
sign = inspect.signature(func)
4141
params_l = len(sign.parameters.keys())

mediatr/mediator.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ def default_handler_class_manager(HandlerCls:type,is_behavior:bool=False):
1515
return HandlerCls()
1616

1717
def extract_request_type(handler, is_behavior=False) -> type:
18-
isfunc = inspect.isfunction(handler)
18+
isfunc = inspect.isroutine(handler)
1919

2020
func = None
2121
if isfunc:
2222
func = handler
2323
else:
2424
if hasattr(handler, 'handle'):
25-
if inspect.isfunction(handler.handle):
25+
if inspect.isroutine(handler.handle):
2626
func = handler.handle
2727
elif inspect.ismethod(handler.handle):
2828
func = handler.__class__.handle
@@ -83,7 +83,7 @@ async def send_async(self: Union["Mediator",GenericQuery[TResponse]], request: O
8383
raise_if_handler_not_found(handler,request)
8484
handler_func = None
8585
handler_obj = None
86-
if inspect.isfunction(handler):
86+
if inspect.isroutine(handler):
8787
handler_func = handler
8888
else:
8989
handler_obj = self1.handler_class_manager(handler)
@@ -95,7 +95,7 @@ async def send_async(self: Union["Mediator",GenericQuery[TResponse]], request: O
9595
async def start_func(i:int):
9696
beh = behaviors[i]
9797
beh_func = None
98-
if inspect.isfunction(beh):
98+
if inspect.isroutine(beh):
9999
beh_func = beh
100100
else:
101101
beh_obj = self1.handler_class_manager(beh, True)
@@ -130,7 +130,7 @@ def send(self: Union["Mediator", GenericQuery[TResponse]], request: Optional[Gen
130130
raise_if_handler_not_found(handler,request)
131131
handler_func = None
132132
handler_obj = None
133-
if inspect.isfunction(handler):
133+
if inspect.isroutine(handler):
134134
handler_func = handler
135135
else:
136136
handler_obj = self1.handler_class_manager(handler)
@@ -141,7 +141,7 @@ def send(self: Union["Mediator", GenericQuery[TResponse]], request: Optional[Gen
141141
def start_func(i:int):
142142
beh = behaviors[i]
143143
beh_func = None
144-
if inspect.isfunction(beh):
144+
if inspect.isroutine(beh):
145145
beh_func = beh
146146
else:
147147
beh_obj = self1.handler_class_manager(beh, True)

0 commit comments

Comments
 (0)