Skip to content

Commit 65de547

Browse files
author
Johan Broberg
committed
revert: Keep Optional[X] syntax, only add docstrings
1 parent 91022ee commit 65de547

3 files changed

Lines changed: 21 additions & 24 deletions

File tree

libraries/microsoft-agents-a365-notifications/microsoft_agents_a365/notifications/models/agent_notification_activity.py

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

4-
from typing import Any, TypeVar
4+
from typing import Any, Optional, Type, TypeVar
55
from microsoft_agents.activity import Activity
6-
7-
from .email_reference import EmailReference
86
from .notification_types import NotificationTypes
7+
from .email_reference import EmailReference
98
from .wpx_comment import WpxComment
109

1110
TModel = TypeVar("TModel")
@@ -42,9 +41,9 @@ def __init__(self, activity: Activity):
4241
if not activity:
4342
raise ValueError("activity parameter is required and cannot be None")
4443
self.activity = activity
45-
self._email: EmailReference | None = None
46-
self._wpx_comment: WpxComment | None = None
47-
self._notification_type: NotificationTypes | None = None
44+
self._email: Optional[EmailReference] = None
45+
self._wpx_comment: Optional[WpxComment] = None
46+
self._notification_type: Optional[NotificationTypes] = None
4847

4948
entities = self.activity.entities or []
5049
for ent in entities:
@@ -75,7 +74,7 @@ def __init__(self, activity: Activity):
7574

7675
# ---- passthroughs ----
7776
@property
78-
def channel(self) -> str | None:
77+
def channel(self) -> Optional[str]:
7978
"""The channel identifier from the activity's channel_id.
8079
8180
Returns:
@@ -85,7 +84,7 @@ def channel(self) -> str | None:
8584
return ch.channel if ch else None
8685

8786
@property
88-
def sub_channel(self) -> str | None:
87+
def sub_channel(self) -> Optional[str]:
8988
"""The subchannel identifier from the activity's channel_id.
9089
9190
Returns:
@@ -104,7 +103,7 @@ def value(self) -> Any:
104103
return self.activity.value
105104

106105
@property
107-
def type(self) -> str | None:
106+
def type(self) -> Optional[str]:
108107
"""The activity type.
109108
110109
Returns:
@@ -114,7 +113,7 @@ def type(self) -> str | None:
114113

115114
# --- typed entities available directly on the activity ---
116115
@property
117-
def email(self) -> EmailReference | None:
116+
def email(self) -> Optional[EmailReference]:
118117
"""The parsed email reference entity, if present.
119118
120119
Returns:
@@ -124,7 +123,7 @@ def email(self) -> EmailReference | None:
124123
return self._email
125124

126125
@property
127-
def wpx_comment(self) -> WpxComment | None:
126+
def wpx_comment(self) -> Optional[WpxComment]:
128127
"""The parsed Word/PowerPoint/Excel comment entity, if present.
129128
130129
Returns:
@@ -134,7 +133,7 @@ def wpx_comment(self) -> WpxComment | None:
134133
return self._wpx_comment
135134

136135
@property
137-
def notification_type(self) -> NotificationTypes | None:
136+
def notification_type(self) -> Optional[NotificationTypes]:
138137
"""The detected notification type.
139138
140139
Returns:
@@ -145,7 +144,7 @@ def notification_type(self) -> NotificationTypes | None:
145144
return self._notification_type
146145

147146
# Generic escape hatch
148-
def as_model(self, model: type[TModel]) -> TModel | None:
147+
def as_model(self, model: Type[TModel]) -> Optional[TModel]:
149148
"""Parse the activity value as a custom model type.
150149
151150
This method provides a generic way to validate and parse the activity's value

libraries/microsoft-agents-a365-notifications/microsoft_agents_a365/notifications/models/email_reference.py

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

4-
from typing import Literal
4+
from typing import Optional, Literal
55
from microsoft_agents.activity.entity import Entity
6-
76
from .notification_types import NotificationTypes
87

98

@@ -21,6 +20,6 @@ class EmailReference(Entity):
2120
"""
2221

2322
type: Literal["emailNotification"] = NotificationTypes.EMAIL_NOTIFICATION
24-
id: str | None = None
25-
conversation_id: str | None = None
26-
html_body: str | None = None
23+
id: Optional[str] = None
24+
conversation_id: Optional[str] = None
25+
html_body: Optional[str] = None

libraries/microsoft-agents-a365-notifications/microsoft_agents_a365/notifications/models/wpx_comment.py

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

4-
from typing import Literal
4+
from typing import Optional, Literal
55
from microsoft_agents.activity.entity import Entity
6-
76
from .notification_types import NotificationTypes
87

98

@@ -24,7 +23,7 @@ class WpxComment(Entity):
2423

2524
type: Literal["wpxComment"] = NotificationTypes.WPX_COMMENT
2625

27-
odata_id: str | None = None
28-
document_id: str | None = None
29-
parent_comment_id: str | None = None
30-
comment_id: str | None = None
26+
odata_id: Optional[str] = None
27+
document_id: Optional[str] = None
28+
parent_comment_id: Optional[str] = None
29+
comment_id: Optional[str] = None

0 commit comments

Comments
 (0)