8000 Rename of run_middleware to run_pipeline in bot_adapter. Removed dupl… · zigri2612/botbuilder-python@0fc44f0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0fc44f0

Browse files
committed
Rename of run_middleware to run_pipeline in bot_adapter. Removed duplicate BotAssert class (new one uses correct variable none-checking)
1 parent c427d8f commit 0fc44f0

File tree

10 files changed

+18
-56
lines changed

10 files changed

+18
-56
lines changed

libraries/botbuilder-ai/botbuilder/ai/luis/luis_recognizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ async def _recognize_internal(
290290
telemetry_metrics: Dict[str, float],
291291
) -> RecognizerResult:
292292

293-
BotAssert.context_not_null(turn_context)
293+
BotAssert.context_not_none(turn_context)
294294

295295
if turn_context.activity.type != ActivityTypes.message:
296296
return None

libraries/botbuilder-core/botbuilder/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from .about import __version__
99
from .activity_handler import ActivityHandler
10-
from .assertions import BotAssert
10+
from .bot_assert import BotAssert
1111
from .bot_adapter import BotAdapter
1212
from .bot_framework_adapter import BotFrameworkAdapter, BotFrameworkAdapterSettings
1313
from .bot_state import BotState

libraries/botbuilder-core/botbuilder/core/adapters/test_adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ async def receive_activity(self, activity):
110110

111111
# Create context object and run middleware
112112
context = TurnContext(self, request)
113-
return await self.run_middleware(context, self.logic)
113+
return await self.run_pipeline(context, self.logic)
114114

115115
async def send(self, user_says) -> object:
116116
"""

libraries/botbuilder-core/botbuilder/core/assertions.py

Lines changed: 0 additions & 40 deletions
This file was deleted.

libraries/botbuilder-core/botbuilder/core/bot_adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def use(self, middleware):
5050
"""
5151
self._middleware.use(middleware)
5252

53-
async def run_middleware(self, context: TurnContext, callback: Callable[[TurnContext], Awaitable]= None):
53+
async def run_pipeline(self, context: TurnContext, callback: Callable[[TurnContext], Awaitable]= None):
5454
"""
5555
Called by the parent class to run the adapters middleware set and calls the passed in `callback()` handler at
5656
the end of the chain.

libraries/botbuilder-core/botbuilder/core/bot_assert.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
14
from typing import List
25

36
from botbuilder.schema import Activity, ConversationReference
@@ -12,7 +15,7 @@ def activity_not_none(activity: Activity) -> None:
1215
Checks that an activity object is not None
1316
:param activity: The activity object
1417
"""
15-
if (activity is None):
18+
if activity is None:
1619
raise TypeError(activity.__class__.__name__)
1720

1821
@staticmethod
@@ -21,7 +24,7 @@ def context_not_none(turn_context: TurnContext) -> None:
2124
Checks that a context object is not None
2225
:param turn_context: The context object
2326
"""
24-
if (turn_context is None):
27+
if turn_context is None:
2528
raise TypeError(turn_context.__class__.__name__)
2629

2730
@staticmethod
@@ -30,7 +33,7 @@ def conversation_reference_not_none(reference: ConversationReference) -> None:
3033
Checks that a conversation reference object is not None
3134
:param reference: The conversation reference object
3235
"""
33-
if (reference is None):
36+
if reference is None:
3437
raise TypeError(reference.__class__.__name__)
3538

3639
@staticmethod
@@ -39,7 +42,7 @@ def activity_list_not_none(activities: List[Activity]) -> None:
3942
Checks that an activity list is not None
4043
:param activities: The activity list
4144
"""
42-
if (activities is None):
45+
if activities is None:
4346
raise TypeError(activities.__class__.__name__)
4447

4548
@staticmethod
@@ -48,7 +51,7 @@ def middleware_not_none(middleware: Middleware) -> None:
4851
Checks that a middleware object is not None
4952
:param middleware: The middleware object
5053
"""
51-
if (middleware is None):
54+
if middleware is None:
5255
raise TypeError(middleware.__class__.__name__)
5356

5457
@staticmethod
@@ -57,7 +60,7 @@ def middleware_list_not_none(middleware: List[Middleware]) -> None:
5760
Checks that a middeware list is not None
5861
:param activities: The middleware list
5962
"""
60-
if (middleware is None):
63+
if middleware is None:
6164
raise TypeError(middleware.__class__.__name__)
6265

6366

libraries/botbuilder-core/botbuilder/core/bot_framework_adapter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async def continue_conversation(self, reference: ConversationReference, logic):
4444
"""
4545
request = TurnContext.apply_conversation_reference(Activity(), reference, is_incoming=True)
4646
context = self.create_context(request)
47-
return await self.run_middleware(context, logic)
47+
return await self.run_pipeline(context, logic)
4848

4949
async def create_conversation(self, reference: ConversationReference, logic: Callable[[TurnContext], Awaitable]=None):
5050
"""
@@ -69,7 +69,7 @@ async def create_conversation(self, reference: ConversationReference, logic: Cal
6969
request.service_url = resource_response.service_url
7070

7171
context = self.create_context(request)
72-
return await self.run_middleware(context, logic)
72+
return await self.run_pipeline(context, logic)
7373

7474
except Exception as e:
7575
raise e
@@ -90,7 +90,7 @@ async def process_activity(self, req, auth_header: str, logic: Callable):
9090
await self.authenticate_request(activity, auth_header)
9191
context = self.create_context(activity)
9292

93-
return await self.run_middleware(context, logic)
93+
return await self.run_pipeline(context, logic)
9494

9595
async def authenticate_request(self, request: Activity, auth_header: str):
9696
"""

libraries/botbuilder-core/botbuilder/core/turn_context.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
ConversationReference,
1111
ResourceResponse
1212
)
13-
from .assertions import BotAssert
1413

1514

1615
class TurnContext(object):

libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_set.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def add(self, dialog: Dialog):
5757
return self
5858

5959
async def create_context(self, turn_context: TurnContext) -> DialogContext:
60-
BotAssert.context_not_null(turn_context)
60+
BotAssert.context_not_none(turn_context)
6161

6262
if not self._dialog_state:
6363
raise RuntimeError("DialogSet.CreateContextAsync(): DialogSet created with a null IStatePropertyAccessor.")

samples/Console-EchoBot/adapter/console_adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ async def process_activity(self, logic: Callable):
8383

8484
activity = TurnContext.apply_conversation_reference(activity, self.reference, True)
8585
context = TurnContext(self, activity)
86-
await self.run_middleware(context, logic)
86+
await self.run_pipeline(context, logic)
8787

8888
async def send_activities(self, context: TurnContext, activities: List[Activity]):
8989
"""

0 commit comments

Comments
 (0)
0