Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/libraries/botbuilder-adapters…
Browse files Browse the repository at this point in the history
…-slack/aiohttp-3.8.5
  • Loading branch information
tracyboehrer authored Oct 11, 2023
2 parents af69b5d + d475640 commit 53e713d
Show file tree
Hide file tree
Showing 76 changed files with 38 additions and 122 deletions.
5 changes: 3 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extension-pkg-whitelist=

# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS,build,botbuilder-schema,samples,django_tests,Generator,operations,operations_async,schema
ignore=CVS,build,botbuilder-schema,samples,django_tests,Generator,operations,operations_async,schema,tests

# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
Expand Down Expand Up @@ -160,7 +160,8 @@ disable=print-statement,
no-name-in-module,
too-many-branches,
too-many-ancestors,
too-many-nested-blocks
too-many-nested-blocks,
attribute-defined-outside-init

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
2 changes: 0 additions & 2 deletions libraries/botbuilder-ai/botbuilder/ai/luis/luis_recognizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ async def _recognize_internal(
LuisPredictionOptions, LuisRecognizerOptionsV2, LuisRecognizerOptionsV3
] = None,
) -> RecognizerResult:

BotAssert.context_not_none(turn_context)

if turn_context.activity.type != ActivityTypes.message:
Expand All @@ -277,7 +276,6 @@ async def _recognize_internal(
text=utterance, intents={"": IntentScore(score=1.0)}, entities={}
)
else:

luis_recognizer = self._build_recognizer(options)
recognizer_result = await luis_recognizer.recognizer_internal(turn_context)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@


class LuisRecognizerV2(LuisRecognizerInternal):

# The value type for a LUIS trace activity.
luis_trace_type: str = "https://www.luis.ai/schemas/trace"

Expand All @@ -43,7 +42,6 @@ def __init__(
self._application = luis_application

async def recognizer_internal(self, turn_context: TurnContext):

utterance: str = (
turn_context.activity.text if turn_context.activity is not None else None
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ async def recognizer_internal(self, turn_context: TurnContext):
return recognizer_result

def _build_url(self):

base_uri = (
self._application.endpoint or "https://westus.api.cognitive.microsoft.com"
)
Expand Down Expand Up @@ -172,7 +171,6 @@ def _extract_entities_and_metadata(self, luis_result):
return self._map_properties(entities, False)

def _map_properties(self, source, in_instance):

if isinstance(source, (int, float, bool, str)):
return source

Expand Down
1 change: 0 additions & 1 deletion libraries/botbuilder-ai/botbuilder/ai/qna/qnamaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ def _validate_options(self, options: QnAMakerOptions):
def _has_matched_answer_in_kb(self, query_results: [QueryResult]) -> bool:
if query_results:
if query_results[0].id != -1:

return True

return False
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ async def step2(step) -> DialogTurnResult:

# Initialize TestAdapter
async def exec_test(turn_context: TurnContext) -> None:

dialog_context = await dialogs.create_context(turn_context)
results = await dialog_context.continue_dialog()
if results.status == DialogTurnStatus.Empty:
Expand Down Expand Up @@ -119,7 +118,6 @@ async def step2(step) -> DialogTurnResult:

# Initialize TestAdapter
async def exec_test(turn_context: TurnContext) -> None:

dialog_context = await dialogs.create_context(turn_context)
await dialog_context.continue_dialog()
if not turn_context.responded:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async def write(self, changes: Dict[str, object]):

await self._initialize()

for (name, item) in changes.items():
for name, item in changes.items():
blob_reference = self.__container_client.get_blob_client(name)

e_tag = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ async def write(self, changes: Dict[str, object]):

await self.initialize()

for (key, change) in changes.items():
for key, change in changes.items():
e_tag = None
if isinstance(change, dict):
e_tag = change.get("e_tag", None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ async def write(self, changes: Dict[str, object]):
if not self.__container_exists:
self.__create_db_and_container()
# iterate over the changes
for (key, change) in changes.items():
for key, change in changes.items():
# store the e_tag
e_tag = None
if isinstance(change, dict):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,6 @@ async def get_user_token(
magic_code: str = None,
oauth_app_credentials: AppCredentials = None, # pylint: disable=unused-argument
) -> TokenResponse:

"""
Attempts to retrieve the token for a user that's in a login flow.
Expand Down
1 change: 0 additions & 1 deletion libraries/botbuilder-core/botbuilder/core/bot_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class CachedBotState:
"""

def __init__(self, state: Dict[str, object] = None):

self.state = state if state is not None else {}
self.hash = self.compute_hash(state)

Expand Down
14 changes: 4 additions & 10 deletions libraries/botbuilder-core/botbuilder/core/bot_state_set.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

from asyncio import wait
from typing import List
from .bot_state import BotState
from .turn_context import TurnContext
Expand All @@ -19,14 +18,9 @@ def add(self, bot_state: BotState) -> "BotStateSet":
return self

async def load_all(self, turn_context: TurnContext, force: bool = False):
await wait(
[bot_state.load(turn_context, force) for bot_state in self.bot_states]
)
for bot_state in self.bot_states:
await bot_state.load(turn_context, force)

async def save_all_changes(self, turn_context: TurnContext, force: bool = False):
await wait(
[
bot_state.save_changes(turn_context, force)
for bot_state in self.bot_states
]
)
for bot_state in self.bot_states:
await bot_state.save_changes(turn_context, force)
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def __init__( # pylint: disable=super-init-not-called
conversation_state: ConversationState = None,
credentials: MicrosoftAppCredentials = None,
):

self.inspection_state = inspection_state
self.inspection_state_accessor = inspection_state.create_property(
"InspectionSessionByStatus"
Expand All @@ -43,13 +42,11 @@ def __init__( # pylint: disable=super-init-not-called

async def process_command(self, context: TurnContext) -> Any:
if context.activity.type == ActivityTypes.message and context.activity.text:

original_text = context.activity.text
TurnContext.remove_recipient_mention(context.activity)

command = context.activity.text.strip().split(" ")
if len(command) > 1 and command[0] == InspectionMiddleware._COMMAND:

if len(command) == 2 and command[1] == "open":
await self._process_open_command(context)
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def write(self, changes: Dict[str, StoreItem]):
return
try:
# iterate over the changes
for (key, change) in changes.items():
for key, change in changes.items():
new_value = deepcopy(change)
old_state_etag = None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def use(self, *middleware: Middleware):
:param middleware :
:return:
"""
for (idx, mid) in enumerate(middleware):
for idx, mid in enumerate(middleware):
if hasattr(mid, "on_turn") and callable(mid.on_turn):
self._middleware.append(mid)
return self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@


class SkillHandler(ChannelServiceHandler):

SKILL_CONVERSATION_REFERENCE_KEY = (
"botbuilder.core.skills.SkillConversationReference"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def can_process_outgoing_activity(self, activity: Activity) -> bool:
return not activity.service_url.startswith("https")

async def process_outgoing_activity(
self, turn_context: TurnContext, activity: Activity
self, _turn_context: TurnContext, activity: Activity
) -> ResourceResponse:
if not activity:
raise TypeError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ async def get_paged_team_members(
async def get_paged_members(
turn_context: TurnContext, continuation_token: str = None, page_size: int = None
) -> List[TeamsPagedMembersResult]:

team_id = TeamsInfo.get_team_id(turn_context)
if not team_id:
conversation_id = turn_context.activity.conversation.id
Expand Down
1 change: 0 additions & 1 deletion libraries/botbuilder-core/botbuilder/core/turn_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@


class TurnContext:

# Same constant as in the BF Adapter, duplicating here to avoid circular dependency
_INVOKE_RESPONSE_KEY = "BotFrameworkAdapter.InvokeResponse"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ async def aux_func_assert_tenant_id_copied(context):
await adapter.process_activity(incoming, "", aux_func_assert_tenant_id_copied)

async def test_should_create_valid_conversation_for_msteams(self):

tenant_id = "testTenant"

reference = deepcopy(REFERENCE)
Expand Down
2 changes: 0 additions & 2 deletions libraries/botbuilder-core/tests/test_inspection_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ async def exec_test(turn_context):
y_prop = conversation_state.create_property("y")

async def exec_test2(turn_context):

await turn_context.send_activity(
MessageFactory.text(f"echo: { turn_context.activity.text }")
)
Expand Down Expand Up @@ -227,7 +226,6 @@ async def exec_test(turn_context):
y_prop = conversation_state.create_property("y")

async def exec_test2(turn_context):

await turn_context.send_activity(
MessageFactory.text(f"echo: {turn_context.activity.text}")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
ConversationReference,
)


# pylint: disable=line-too-long,missing-docstring
class TestMemoryTranscriptStore(aiounittest.AsyncTestCase):
# pylint: disable=unused-argument
Expand Down
1 change: 0 additions & 1 deletion libraries/botbuilder-core/tests/test_message_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def assert_attachments(activity: Activity, count: int, types: List[str] = None):


class TestMessageFactory(aiounittest.AsyncTestCase):

suggested_actions = [
CardAction(title="a", type=ActionTypes.im_back, value="a"),
CardAction(title="b", type=ActionTypes.im_back, value="b"),
Expand Down
1 change: 0 additions & 1 deletion libraries/botbuilder-core/tests/test_middleware_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ async def request_handler(context_or_string):
await middleware_set.receive_activity_internal("Bye", request_handler)

async def test_middleware_run_in_order(self):

called_first = False
called_second = False

Expand Down
2 changes: 1 addition & 1 deletion libraries/botbuilder-core/tests/test_turn_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def send_activities(self, context, activities) -> List[ResourceResponse]:
assert activities is not None
assert isinstance(activities, list)
assert activities
for (idx, activity) in enumerate(activities): # pylint: disable=unused-variable
for idx, activity in enumerate(activities): # pylint: disable=unused-variable
assert isinstance(activity, Activity)
assert activity.type == "message" or activity.type == ActivityTypes.trace
responses.append(ResourceResponse(id="5678"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def find_values(
)

for entry in sorted_values:

# Find all matches for a value
# - To match "last one" in "the last time I chose the last one" we need
# to re-search the string starting from the end of the previous match.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ async def on_dialog_event(

# Trace unhandled "versionChanged" events.
if not handled and dialog_event.name == DialogEvents.version_changed:

trace_message = (
f"Unhandled dialog event: {dialog_event.name}. Active Dialog: "
f"{dialog_context.active_dialog.id}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class DialogEvents(str, Enum):

begin_dialog = "beginDialog"
reprompt_dialog = "repromptDialog"
cancel_dialog = "cancelDialog"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
# PathResolvers allow for shortcut behavior for mapping things like $foo -> dialog.foo.
# </summary>
class DialogStateManager:

SEPARATORS = [",", "["]

def __init__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class AtPathResolver(AliasPathResolver):

_DELIMITERS = [".", "["]

def __init__(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _bind_to_dialog_context(obj, dialog_context: "DialogContext") -> object:
if hasattr(prop_value, "try_get_value"):
clone[prop] = prop_value.try_get_value(dialog_context.state)
elif hasattr(prop_value, "__dict__") and not isinstance(
prop_value, type
prop_value, type(prop_value)
):
clone[prop] = ClassMemoryScope._bind_to_dialog_context(
prop_value, dialog_context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def add_step(self, step):
async def begin_dialog(
self, dialog_context: DialogContext, options: object = None
) -> DialogTurnResult:

if not dialog_context:
raise TypeError("WaterfallDialog.begin_dialog(): dc cannot be None.")

Expand Down Expand Up @@ -113,7 +112,6 @@ async def end_dialog( # pylint: disable=unused-argument
self.telemetry_client.track_event("WaterfallCancel", properties)
else:
if reason is DialogReason.EndCalled:

instance_id = str(instance.state[self.PersistedInstanceId])
properties = {"DialogId": self.id, "InstanceId": instance_id}
self.telemetry_client.track_event("WaterfallComplete", properties)
Expand Down
1 change: 0 additions & 1 deletion libraries/botbuilder-dialogs/tests/test_confirm_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ async def exec_test(turn_context: TurnContext):

async def test_confirm_prompt_should_default_to_english_locale(self):
async def exec_test(turn_context: TurnContext):

dialog_context = await dialogs.create_context(turn_context)

results: DialogTurnResult = await dialog_context.continue_dialog()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ async def exec_test(turn_context: TurnContext) -> None:

results = await dialog_context.continue_dialog()
if results.status == DialogTurnStatus.Empty:

options = PromptOptions(prompt=MessageFactory.text(prompt_msg))
await dialog_context.begin_dialog("DateTimePrompt", options)
else:
Expand Down
1 change: 0 additions & 1 deletion libraries/botbuilder-dialogs/tests/test_number_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ async def test_number_uses_locale_specified_in_constructor(self):
dialogs.add(number_prompt)

async def exec_test(turn_context: TurnContext) -> None:

dialog_context = await dialogs.create_context(turn_context)
results = await dialog_context.continue_dialog()

Expand Down
2 changes: 0 additions & 2 deletions libraries/botbuilder-dialogs/tests/test_oauth_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ async def callback_handler(turn_context: TurnContext):
async def inspector(
activity: Activity, description: str = None
): # pylint: disable=unused-argument

self.assertTrue(len(activity.attachments) == 1)
self.assertTrue(
activity.attachments[0].content_type
Expand Down Expand Up @@ -184,7 +183,6 @@ async def exec_test(turn_context: TurnContext):

results = await dialog_context.continue_dialog()
if results.status == DialogTurnStatus.Empty:

# If magicCode is detected when prompting, this will end the dialog and return the token in tokenResult
token_result = await dialog_context.prompt("prompt", PromptOptions())
if isinstance(token_result.result, TokenResponse):
Expand Down
Loading

0 comments on commit 53e713d

Please sign in to comment.