Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ disable=print-statement,
too-many-locals,
too-many-function-args,
too-many-return-statements,
import-error
import-error,
no-name-in-module

# 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
11 changes: 4 additions & 7 deletions libraries/botbuilder-ai/botbuilder/ai/luis/luis_recognizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@
from azure.cognitiveservices.language.luis.runtime.models import LuisResult
from msrest.authentication import CognitiveServicesCredentials

from botbuilder.core import (
BotAssert,
IntentScore,
RecognizerResult,
TurnContext,
)
from botbuilder.core import BotAssert, IntentScore, RecognizerResult, TurnContext
from botbuilder.schema import ActivityTypes

from . import LuisApplication, LuisPredictionOptions, LuisTelemetryConstants
Expand Down Expand Up @@ -158,7 +153,9 @@ def on_recognizer_result(

@staticmethod
def _get_top_k_intent_score(
intent_names: List[str], intents: Dict[str, IntentScore], index: int # pylint: disable=unused-argument
intent_names: List[str],
intents: Dict[str, IntentScore],
index: int, # pylint: disable=unused-argument
) -> Tuple[str, str]:
intent_name = ""
intent_score = "0.00"
Expand Down
7 changes: 4 additions & 3 deletions libraries/botbuilder-ai/tests/luis/luis_application_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ def test_list_application_from_luis_endpoint(self) -> None:
# Arrange
# Note this is NOT a real LUIS application ID nor a real LUIS subscription-key
# theses are GUIDs edited to look right to the parsing and validation code.
endpoint = \
"https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/" \
"b31aeaf3-3511-495b-a07f-571fc873214b?verbose=true&timezoneOffset=-360" \
endpoint = (
"https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/"
"b31aeaf3-3511-495b-a07f-571fc873214b?verbose=true&timezoneOffset=-360"
"&subscription-key=048ec46dc58e495482b0c447cfdbd291&q="
)

# Act
app = LuisApplication.from_application_endpoint(endpoint)
Expand Down
24 changes: 15 additions & 9 deletions libraries/botbuilder-ai/tests/luis/luis_recognizer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ def __init__(self, *args, **kwargs):

def test_luis_recognizer_construction(self):
# Arrange
endpoint = "https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/" \
"b31aeaf3-3511-495b-a07f-571fc873214b?verbose=true&timezoneOffset=-360" \
"&subscription-key=048ec46dc58e495482b0c447cfdbd291&q="
endpoint = (
"https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/"
"b31aeaf3-3511-495b-a07f-571fc873214b?verbose=true&timezoneOffset=-360"
"&subscription-key=048ec46dc58e495482b0c447cfdbd291&q="
)

# Act
recognizer = LuisRecognizer(endpoint)
Expand All @@ -69,9 +71,11 @@ def test_luis_recognizer_construction(self):
self.assertEqual("https://westus.api.cognitive.microsoft.com", app.endpoint)

def test_luis_recognizer_timeout(self):
endpoint = "https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/" \
"b31aeaf3-3511-495b-a07f-571fc873214b?verbose=true&timezoneOffset=-360" \
"&subscription-key=048ec46dc58e495482b0c447cfdbd291&q="
endpoint = (
"https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/"
"b31aeaf3-3511-495b-a07f-571fc873214b?verbose=true&timezoneOffset=-360"
"&subscription-key=048ec46dc58e495482b0c447cfdbd291&q="
)
expected_timeout = 300
options_with_timeout = LuisPredictionOptions(timeout=expected_timeout * 1000)

Expand Down Expand Up @@ -436,9 +440,11 @@ def test_telemetry_construction(self):
# Arrange
# Note this is NOT a real LUIS application ID nor a real LUIS subscription-key
# theses are GUIDs edited to look right to the parsing and validation code.
endpoint = "https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/" \
"b31aeaf3-3511-495b-a07f-571fc873214b?verbose=true&timezoneOffset=-360" \
"&subscription-key=048ec46dc58e495482b0c447cfdbd291&q="
endpoint = (
"https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/"
"b31aeaf3-3511-495b-a07f-571fc873214b?verbose=true&timezoneOffset=-360"
"&subscription-key=048ec46dc58e495482b0c447cfdbd291&q="
)

# Act
recognizer = LuisRecognizer(endpoint)
Expand Down
18 changes: 8 additions & 10 deletions libraries/botbuilder-ai/tests/qna/test_qna.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
QnATelemetryConstants,
QueryResult,
)
from botbuilder.core import (
BotAdapter,
BotTelemetryClient,
TurnContext,
)
from botbuilder.core import BotAdapter, BotTelemetryClient, TurnContext
from botbuilder.core.adapters import TestAdapter
from botbuilder.schema import (
Activity,
Expand All @@ -40,7 +36,9 @@ def __init__(self, request):

self.on_send_activities(self.capture_sent_activities)

async def capture_sent_activities(self, context: TurnContext, activities, next): # pylint: disable=unused-argument
async def capture_sent_activities(
self, context: TurnContext, activities, next
): # pylint: disable=unused-argument
self.sent += activities
context.responded = True

Expand Down Expand Up @@ -722,7 +720,7 @@ def _get_context(question: str, bot_adapter: BotAdapter) -> TurnContext:
return TurnContext(test_adapter, activity)

class OverrideTelemetry(QnAMaker):
def __init__(
def __init__( # pylint: disable=useless-super-delegation
self,
endpoint: QnAMakerEndpoint,
options: QnAMakerOptions,
Expand All @@ -738,10 +736,10 @@ def __init__(
log_personal_information,
)

async def on_qna_result(
async def on_qna_result( # pylint: disable=unused-argument
self,
query_results: [QueryResult],
turn_context: TurnContext, # pylint: disable=unused-argument
turn_context: TurnContext,
telemetry_properties: Dict[str, str] = None,
telemetry_metrics: Dict[str, float] = None,
):
Expand All @@ -762,7 +760,7 @@ async def on_qna_result(
)

class OverrideFillTelemetry(QnAMaker):
def __init__(
def __init__( # pylint: disable=useless-super-delegation
self,
endpoint: QnAMakerEndpoint,
options: QnAMakerOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def test_none_telemetry_client(self):
self.assertEqual(type(dialog.telemetry_client), NullTelemetryClient)

@patch("botbuilder.applicationinsights.ApplicationInsightsTelemetryClient")
async def test_execute_sequence_waterfall_steps(self, MockTelemetry): # pylint: disable=invalid-name
async def test_execute_sequence_waterfall_steps( # pylint: disable=invalid-name
self, MockTelemetry
):
# arrange

# Create new ConversationState with MemoryStorage and register the state as middleware.
Expand Down Expand Up @@ -91,7 +93,9 @@ async def exec_test(turn_context: TurnContext) -> None:
self.assert_telemetry_calls(telemetry, telemetry_calls)

@patch("botbuilder.applicationinsights.ApplicationInsightsTelemetryClient")
async def test_ensure_end_dialog_called(self, MockTelemetry): # pylint: disable=invalid-name
async def test_ensure_end_dialog_called(
self, MockTelemetry
): # pylint: disable=invalid-name
# arrange

# Create new ConversationState with MemoryStorage and register the state as middleware.
Expand Down Expand Up @@ -150,7 +154,8 @@ async def exec_test(turn_context: TurnContext) -> None:
def assert_telemetry_call(
self, telemetry_mock, index: int, event_name: str, props: Dict[str, str]
) -> None:
args, kwargs = telemetry_mock.track_event.call_args_list[index] # pylint: disable=unused-variable
# pylint: disable=unused-variable
args, kwargs = telemetry_mock.track_event.call_args_list[index]
self.assertEqual(args[0], event_name)

for key, val in props.items():
Expand Down
12 changes: 7 additions & 5 deletions libraries/botbuilder-azure/botbuilder/azure/cosmosdb_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ def __create_dict(self, store_item: StoreItem) -> Dict:
"""
# read the content
non_magic_attr = [
attr for attr in dir(store_item) if not attr.startswith("_") or attr.__eq__("e_tag")
attr
for attr in dir(store_item)
if not attr.startswith("_") or attr.__eq__("e_tag")
]
# loop through attributes and write and return a dict
return {attr: getattr(store_item, attr) for attr in non_magic_attr}
Expand Down Expand Up @@ -294,7 +296,9 @@ def __create_db_and_container(self):
self.database = self._get_or_create_database(self.client, db_id)
self.container = self._get_or_create_container(self.client, container_name)

def _get_or_create_database(self, doc_client, id) -> str: # pylint: disable=invalid-name
def _get_or_create_database( # pylint: disable=invalid-name
self, doc_client, id
) -> str:
"""Return the database link.

Check if the database exists or create the database.
Expand Down Expand Up @@ -345,8 +349,6 @@ def _get_or_create_container(self, doc_client, container) -> str:

# Create a container if it didn't exist
res = doc_client.CreateContainer(
self.__database_link,
{"id": container},
self._container_creation_options,
self.__database_link, {"id": container}, self._container_creation_options
)
return res["id"]
16 changes: 12 additions & 4 deletions libraries/botbuilder-core/botbuilder/core/activity_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ async def on_turn(self, turn_context: TurnContext):
else:
await self.on_unrecognized_activity_type(turn_context)

async def on_message_activity(self, turn_context: TurnContext): # pylint: disable=unused-argument
async def on_message_activity( # pylint: disable=unused-argument
self, turn_context: TurnContext
):
return

async def on_conversation_update_activity(self, turn_context: TurnContext):
Expand Down Expand Up @@ -68,11 +70,17 @@ async def on_event_activity(self, turn_context: TurnContext):

return await self.on_event(turn_context)

async def on_token_response_event(self, turn_context: TurnContext): # pylint: disable=unused-argument
async def on_token_response_event( # pylint: disable=unused-argument
self, turn_context: TurnContext
):
return

async def on_event(self, turn_context: TurnContext): # pylint: disable=unused-argument
async def on_event( # pylint: disable=unused-argument
self, turn_context: TurnContext
):
return

async def on_unrecognized_activity_type(self, turn_context: TurnContext): # pylint: disable=unused-argument
async def on_unrecognized_activity_type( # pylint: disable=unused-argument
self, turn_context: TurnContext
):
return
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(
logic: Coroutine = None,
conversation: ConversationReference = None,
send_trace_activity: bool = False,
): # pylint: disable=unused-argument
): # pylint: disable=unused-argument
"""
Creates a new TestAdapter instance.
:param logic:
Expand Down Expand Up @@ -242,10 +242,7 @@ async def get_user_token(
magic_code_record = list(
filter(lambda x: key.equals_key(x.key), self._magic_codes)
)
if (
magic_code_record
and magic_code_record[0].magic_code == magic_code
):
if magic_code_record and magic_code_record[0].magic_code == magic_code:
# Move the token to long term dictionary.
self.add_user_token(
connection_name,
Expand All @@ -269,7 +266,9 @@ async def get_user_token(
# Not found.
return None

async def sign_out_user(self, context: TurnContext, connection_name: str, user_id: str = None):
async def sign_out_user(
self, context: TurnContext, connection_name: str, user_id: str = None
):
channel_id = context.activity.channel_id
user_id = context.activity.from_property.id

Expand All @@ -286,8 +285,10 @@ async def sign_out_user(self, context: TurnContext, connection_name: str, user_i
async def get_oauth_sign_in_link(
self, context: TurnContext, connection_name: str
) -> str:
return f"https://fake.com/oauthsignin" \
return (
f"https://fake.com/oauthsignin"
f"/{connection_name}/{context.activity.channel_id}/{context.activity.from_property.id}"
)

async def get_aad_tokens(
self, context: TurnContext, connection_name: str, resource_urls: List[str]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ def get_storage_key(self, turn_context: TurnContext) -> object:
channel_id = turn_context.activity.channel_id or self.__raise_type_error(
"invalid activity-missing channel_id"
)
conversation_id = turn_context.activity.conversation.id or self.__raise_type_error(
"invalid activity-missing conversation.id"
conversation_id = (
turn_context.activity.conversation.id
or self.__raise_type_error("invalid activity-missing conversation.id")
)

storage_key = None
Expand Down
8 changes: 6 additions & 2 deletions libraries/botbuilder-core/botbuilder/core/middleware_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

class Middleware(ABC):
@abstractmethod
def on_process_request(self, context: TurnContext, logic: Callable[[TurnContext], Awaitable]):
def on_process_request(
self, context: TurnContext, logic: Callable[[TurnContext], Awaitable]
):
pass


Expand All @@ -22,7 +24,9 @@ def __init__(self, anonymous_handler):
)
self._to_call = anonymous_handler

def on_process_request(self, context: TurnContext, logic: Callable[[TurnContext], Awaitable]):
def on_process_request(
self, context: TurnContext, logic: Callable[[TurnContext], Awaitable]
):
return self._to_call(context, logic)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

class StatePropertyAccessor(ABC):
@abstractmethod
async def get(self, turn_context: TurnContext, default_value_factory=None) -> object:
async def get(
self, turn_context: TurnContext, default_value_factory=None
) -> object:
"""
Get the property value from the source
:param turn_context: Turn Context.
Expand Down
16 changes: 10 additions & 6 deletions libraries/botbuilder-core/botbuilder/core/turn_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ def __init__(self, adapter_or_context, request: Activity = None):
self._activity = request
self.responses: List[Activity] = []
self._services: dict = {}
self._on_send_activities: Callable[["TurnContext", List[Activity], Callable], List[ResourceResponse]] = []
self._on_update_activity: Callable[["TurnContext", Activity, Callable], ResourceResponse] = []
self._on_delete_activity: Callable[["TurnContext", ConversationReference, Callable], None] = []
self._on_send_activities: Callable[
["TurnContext", List[Activity], Callable], List[ResourceResponse]
] = []
self._on_update_activity: Callable[
["TurnContext", Activity, Callable], ResourceResponse
] = []
self._on_delete_activity: Callable[
["TurnContext", ConversationReference, Callable], None
] = []
self._responded: bool = False

if self.adapter is None:
Expand Down Expand Up @@ -158,9 +164,7 @@ async def callback(context: "TurnContext", output):
self._on_send_activities, output, callback(self, output)
)

return (
result[0] if result else ResourceResponse()
)
return result[0] if result else ResourceResponse()

async def update_activity(self, activity: Activity):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ async def get_user_token(
raise NotImplementedError()

@abstractmethod
async def sign_out_user(self, context: TurnContext, connection_name: str, user_id: str = None):
async def sign_out_user(
self, context: TurnContext, connection_name: str, user_id: str = None
):
"""
Signs the user out with the token server.
:param context:
Expand Down
4 changes: 3 additions & 1 deletion libraries/botbuilder-core/tests/call_counting_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class CallCountingMiddleware(Middleware):
def __init__(self):
self.counter = 0

def on_process_request(self, context: TurnContext, logic: Callable[[TurnContext], Awaitable]):
def on_process_request( # pylint: disable=unused-argument
self, context: TurnContext, logic: Callable[[TurnContext], Awaitable]
):
self.counter += 1
logic()
Loading