Skip to content

Commit 422e69e

Browse files
committed
Fix optional typing issue
1 parent bd5662a commit 422e69e

File tree

59 files changed

+603
-571
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+603
-571
lines changed

generators/app/templates/core/{{cookiecutter.bot_name}}/booking_details.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33

4-
from typing import List
4+
from typing import List, Union
55

66

77
class BookingDetails:
88
def __init__(
99
self,
10-
destination: str = None,
11-
origin: str = None,
12-
travel_date: str = None,
10+
destination: Union[str, None] = None,
11+
origin: Union[str, None] = None,
12+
travel_date: Union[str, None] = None,
1313
unsupported_airports: List[str] = None,
1414
):
1515
self.destination = destination

generators/app/templates/core/{{cookiecutter.bot_name}}/dialogs/date_resolver_dialog.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33

4+
from typing import Union
5+
46
from botbuilder.core import MessageFactory
57
from botbuilder.dialogs import WaterfallDialog, DialogTurnResult, WaterfallStepContext
68
from botbuilder.dialogs.prompts import (
@@ -16,7 +18,7 @@
1618

1719

1820
class DateResolverDialog(CancelAndHelpDialog):
19-
def __init__(self, dialog_id: str = None):
21+
def __init__(self, dialog_id: Union[str, None] = None):
2022
super(DateResolverDialog, self).__init__(
2123
dialog_id or DateResolverDialog.__name__
2224
)

libraries/botbuilder-adapters-slack/botbuilder/adapters/slack/slack_adapter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the MIT License.
33

44
from abc import ABC
5-
from typing import List, Callable, Awaitable
5+
from typing import List, Callable, Awaitable, Union
66

77
from aiohttp.web_request import Request
88
from aiohttp.web_response import Response
@@ -143,9 +143,9 @@ async def continue_conversation(
143143
self,
144144
reference: ConversationReference,
145145
callback: Callable,
146-
bot_id: str = None, # pylint: disable=unused-argument
146+
bot_id: Union[str, None] = None, # pylint: disable=unused-argument
147147
claims_identity: ClaimsIdentity = None,
148-
audience: str = None, # pylint: disable=unused-argument
148+
audience: Union[str, None] = None, # pylint: disable=unused-argument
149149
):
150150
"""
151151
Send a proactive message to a conversation.

libraries/botbuilder-adapters-slack/botbuilder/adapters/slack/slack_client.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ async def users_counts(self) -> SlackResponse:
8686
async def im_history_ex(
8787
self,
8888
channel: str,
89-
latest_timestamp: str = None,
90-
oldest_timestamp: str = None,
91-
count: int = None,
92-
unreads: bool = None,
89+
latest_timestamp: Union[str, None] = None,
90+
oldest_timestamp: Union[str, None] = None,
91+
count: Union[int, None] = None,
92+
unreads: Union[bool, None] = None,
9393
) -> SlackResponse:
9494
args = {}
9595
if latest_timestamp:
@@ -104,18 +104,18 @@ async def im_history_ex(
104104
return await self.im_history(channel=channel, **args)
105105

106106
async def files_info_ex(
107-
self, file_id: str, page: int = None, count: int = None
107+
self, file_id: str, page: Union[int, None] = None, count: Union[int, None] = None
108108
) -> SlackResponse:
109109
args = {"count": str(count), "page": str(page)}
110110
return await self.files_info(file=file_id, **args)
111111

112112
async def files_list_ex(
113113
self,
114-
user_id: str = None,
115-
date_from: str = None,
116-
date_to: str = None,
117-
count: int = None,
118-
page: int = None,
114+
user_id: Union[str, None] = None,
115+
date_from: Union[str, None] = None,
116+
date_to: Union[str, None] = None,
117+
count: Union[int, None] = None,
118+
page: Union[int, None] = None,
119119
types: List[str] = None,
120120
) -> SlackResponse:
121121
args = {}
@@ -139,7 +139,7 @@ async def files_list_ex(
139139
return await self.files_list(**args)
140140

141141
async def groups_history_ex(
142-
self, channel: str, latest: str = None, oldest: str = None, count: int = None
142+
self, channel: str, latest: Union[str, None] = None, oldest: Union[str, None] = None, count: Union[int, None] = None
143143
) -> SlackResponse:
144144
args = {}
145145

@@ -161,7 +161,7 @@ async def get_preferences(self) -> SlackResponse:
161161
return await self.api_call("users.prefs.get", http_verb="GET")
162162

163163
async def stars_list_ex(
164-
self, user: str = None, count: int = None, page: int = None
164+
self, user: Union[str, None] = None, count: Union[int, None] = None, page: Union[int, None] = None
165165
) -> SlackResponse:
166166
args = {}
167167

@@ -183,7 +183,7 @@ async def chat_post_ephemeral_ex(
183183
channel: str,
184184
text: str,
185185
target_user: str,
186-
parse: str = None,
186+
parse: Union[str, None] = None,
187187
link_names: bool = False,
188188
attachments: List[str] = None, # pylint: disable=unused-argument
189189
as_user: bool = False,
@@ -207,14 +207,14 @@ async def chat_post_message_ex(
207207
self,
208208
channel: str,
209209
text: str,
210-
bot_name: str = None,
211-
parse: str = None,
210+
bot_name: Union[str, None] = None,
211+
parse: Union[str, None] = None,
212212
link_names: bool = False,
213213
blocks: List[str] = None, # pylint: disable=unused-argument
214214
attachments: List[str] = None, # pylint: disable=unused-argument
215215
unfurl_links: bool = False,
216-
icon_url: str = None,
217-
icon_emoji: str = None,
216+
icon_url: Union[str, None] = None,
217+
icon_emoji: Union[str, None] = None,
218218
as_user: bool = False,
219219
) -> SlackResponse:
220220
args = {
@@ -248,11 +248,11 @@ async def chat_post_message_ex(
248248
async def search_all_ex(
249249
self,
250250
query: str,
251-
sorting: str = None,
252-
direction: str = None,
251+
sorting: Union[str, None] = None,
252+
direction: Union[str, None] = None,
253253
enable_highlights: bool = False,
254-
count: int = None,
255-
page: int = None,
254+
count: Union[int, None] = None,
255+
page: Union[int, None] = None,
256256
) -> SlackResponse:
257257
args = {"highlight": "1" if enable_highlights else "0"}
258258

@@ -273,11 +273,11 @@ async def search_all_ex(
273273
async def search_files_ex(
274274
self,
275275
query: str,
276-
sorting: str = None,
277-
direction: str = None,
276+
sorting: Union[str, None] = None,
277+
direction: Union[str, None] = None,
278278
enable_highlights: bool = False,
279-
count: int = None,
280-
page: int = None,
279+
count: Union[int, None] = None,
280+
page: Union[int, None] = None,
281281
) -> SlackResponse:
282282
args = {"highlight": "1" if enable_highlights else "0"}
283283

@@ -298,11 +298,11 @@ async def search_files_ex(
298298
async def search_messages_ex(
299299
self,
300300
query: str,
301-
sorting: str = None,
302-
direction: str = None,
301+
sorting: Union[str, None] = None,
302+
direction: Union[str, None] = None,
303303
enable_highlights: bool = False,
304-
count: int = None,
305-
page: int = None,
304+
count: Union[int, None] = None,
305+
page: Union[int, None] = None,
306306
) -> SlackResponse:
307307
args = {"highlight": "1" if enable_highlights else "0"}
308308

@@ -325,8 +325,8 @@ async def chat_update_ex(
325325
timestamp: str,
326326
channel: str,
327327
text: str,
328-
bot_name: str = None,
329-
parse: str = None,
328+
bot_name: Union[str, None] = None,
329+
parse: Union[str, None] = None,
330330
link_names: bool = False,
331331
attachments: List[str] = None, # pylint: disable=unused-argument
332332
as_user: bool = False,
@@ -352,11 +352,11 @@ async def chat_update_ex(
352352
async def files_upload_ex(
353353
self,
354354
file: Union[str, IOBase] = None,
355-
content: str = None,
355+
content: Union[str, None] = None,
356356
channels: List[str] = None,
357-
title: str = None,
358-
initial_comment: str = None,
359-
file_type: str = None,
357+
title: Union[str, None] = None,
358+
initial_comment: Union[str, None] = None,
359+
file_type: Union[str, None] = None,
360360
):
361361
args = {}
362362

libraries/botbuilder-ai/botbuilder/ai/qna/qna_dialog_response_options.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33

4+
from typing import Union
5+
46
from botbuilder.schema import Activity
57

68

79
class QnADialogResponseOptions:
810
def __init__(
911
self,
10-
active_learning_card_title: str = None,
11-
card_no_match_text: str = None,
12+
active_learning_card_title: Union[str, None] = None,
13+
card_no_match_text: Union[str, None] = None,
1214
no_answer: Activity = None,
1315
card_no_match_response: Activity = None,
1416
):

libraries/botbuilder-applicationinsights/botbuilder/applicationinsights/application_insights_telemetry_client.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""Application Insights Telemetry Client for Bots."""
44

55
import traceback
6-
from typing import Dict, Callable
6+
from typing import Dict, Callable, Union
77

88
from applicationinsights import TelemetryClient # pylint: disable=no-name-in-module
99
from botbuilder.core.bot_telemetry_client import (
@@ -38,7 +38,7 @@ def __init__(
3838
instrumentation_key: str,
3939
telemetry_client: TelemetryClient = None,
4040
telemetry_processor: Callable[[object, object], bool] = None,
41-
client_queue_size: int = None,
41+
client_queue_size: Union[int, None] = None,
4242
):
4343
self._instrumentation_key = instrumentation_key
4444

@@ -131,7 +131,7 @@ def track_metric(
131131
name: str,
132132
value: float,
133133
tel_type: TelemetryDataPointType = None,
134-
count: int = None,
134+
count: Union[int, None] = None,
135135
min_val: float = None,
136136
max_val: float = None,
137137
std_dev: float = None,
@@ -182,13 +182,13 @@ def track_request(
182182
name: str,
183183
url: str,
184184
success: bool,
185-
start_time: str = None,
186-
duration: int = None,
187-
response_code: str = None,
188-
http_method: str = None,
185+
start_time: Union[str, None] = None,
186+
duration: Union[int, None] = None,
187+
response_code: Union[str, None] = None,
188+
http_method: Union[str, None] = None,
189189
properties: Dict[str, object] = None,
190190
measurements: Dict[str, object] = None,
191-
request_id: str = None,
191+
request_id: Union[str, None] = None,
192192
):
193193
"""
194194
Sends a single request that was captured for the application.
@@ -233,14 +233,14 @@ def track_dependency(
233233
self,
234234
name: str,
235235
data: str,
236-
type_name: str = None,
237-
target: str = None,
238-
duration: int = None,
239-
success: bool = None,
240-
result_code: str = None,
236+
type_name: Union[str, None] = None,
237+
target: Union[str, None] = None,
238+
duration: Union[int, None] = None,
239+
success: Union[bool, None] = None,
240+
result_code: Union[str, None] = None,
241241
properties: Dict[str, object] = None,
242242
measurements: Dict[str, object] = None,
243-
dependency_id: str = None,
243+
dependency_id: Union[str, None] = None,
244244
):
245245
"""
246246
Sends a single dependency telemetry that was captured for the application.

libraries/botbuilder-azure/botbuilder/azure/cosmosdb_partitioned_storage.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Copyright (c) Microsoft Corporation. All rights reserved.
55
# Licensed under the MIT License.
6-
from typing import Dict, List
6+
from typing import Dict, List, Union
77
from threading import Lock
88
import json
99
from hashlib import sha256
@@ -21,10 +21,10 @@ class CosmosDbPartitionedConfig:
2121

2222
def __init__(
2323
self,
24-
cosmos_db_endpoint: str = None,
25-
auth_key: str = None,
26-
database_id: str = None,
27-
container_id: str = None,
24+
cosmos_db_endpoint: Union[str, None] = None,
25+
auth_key: Union[str, None] = None,
26+
database_id: Union[str, None] = None,
27+
container_id: Union[str, None] = None,
2828
cosmos_client_options: dict = None,
2929
container_throughput: int = 400,
3030
key_suffix: str = "",

0 commit comments

Comments
 (0)