Skip to content

Commit 0e3573a

Browse files
CopilotJimDaly
andcommitted
Fix docstring code examples: replace triple backtick fences with Google Style doctest format
Co-authored-by: JimDaly <6353736+JimDaly@users.noreply.github.com>
1 parent e6a67a7 commit 0e3573a

4 files changed

Lines changed: 84 additions & 118 deletions

File tree

libraries/microsoft-agents-a365-notifications/microsoft_agents_a365/notifications/agent_notification.py

Lines changed: 62 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,14 @@
2929
#: notification: The typed notification activity with parsed entities.
3030
#:
3131
#: Example:
32-
#: ```python
33-
#: async def handle_email(
34-
#: context: TurnContext,
35-
#: state: TurnState,
36-
#: notification: AgentNotificationActivity
37-
#: ) -> None:
38-
#: email = notification.email
39-
#: if email:
40-
#: print(f"Processing email: {email.id}")
41-
#: ```
32+
#: >>> async def handle_email(
33+
#: ... context: TurnContext,
34+
#: ... state: TurnState,
35+
#: ... notification: AgentNotificationActivity,
36+
#: ... ) -> None:
37+
#: ... email = notification.email
38+
#: ... if email:
39+
#: ... print(f"Processing email: {email.id}")
4240
AgentHandler = Callable[[TContext, TState, AgentNotificationActivity], Awaitable[None]]
4341

4442

@@ -57,19 +55,15 @@ class AgentNotification:
5755
defaults to all values in the AgentLifecycleEvent enum.
5856
5957
Example:
60-
```python
61-
from microsoft_agents.hosting import Application
62-
from microsoft_agents_a365.notifications import AgentNotification
63-
64-
app = Application()
65-
notifications = AgentNotification(app)
66-
67-
@notifications.on_email()
68-
async def handle_email(context, state, notification):
69-
email = notification.email
70-
if email:
71-
await context.send_activity(f"Received email: {email.id}")
72-
```
58+
>>> from microsoft_agents.hosting import Application
59+
>>> from microsoft_agents_a365.notifications import AgentNotification
60+
>>> app = Application()
61+
>>> notifications = AgentNotification(app)
62+
>>> @notifications.on_email()
63+
... async def handle_email(context, state, notification):
64+
... email = notification.email
65+
... if email:
66+
... await context.send_activity(f"Received email: {email.id}")
7367
"""
7468

7569
def __init__(
@@ -126,15 +120,12 @@ def on_agent_notification(
126120
A decorator function that registers the handler with the application.
127121
128122
Example:
129-
```python
130-
from microsoft_agents.activity import ChannelId
131-
132-
@notifications.on_agent_notification(
133-
ChannelId(channel="agents", sub_channel="email")
134-
)
135-
async def handle_custom_channel(context, state, notification):
136-
print(f"Received notification on {notification.channel}/{notification.sub_channel}")
137-
```
123+
>>> from microsoft_agents.activity import ChannelId
124+
>>> @notifications.on_agent_notification(
125+
... ChannelId(channel="agents", sub_channel="email")
126+
... )
127+
... async def handle_custom_channel(context, state, notification):
128+
... print(f"Received notification on {notification.channel}/{notification.sub_channel}")
138129
"""
139130
registered_channel = channel_id.channel.lower()
140131
registered_subchannel = (channel_id.sub_channel or "*").lower()
@@ -184,11 +175,9 @@ def on_agent_lifecycle_notification(
184175
A decorator function that registers the handler with the application.
185176
186177
Example:
187-
```python
188-
@notifications.on_agent_lifecycle_notification("agenticuseridentitycreated")
189-
async def handle_user_created(context, state, notification):
190-
print("New user created")
191-
```
178+
>>> @notifications.on_agent_lifecycle_notification("agenticuseridentitycreated")
179+
... async def handle_user_created(context, state, notification):
180+
... print("New user created")
192181
"""
193182

194183
def route_selector(context: TurnContext) -> bool:
@@ -234,18 +223,15 @@ def on_email(
234223
A decorator function that registers the handler with the application.
235224
236225
Example:
237-
```python
238-
@notifications.on_email()
239-
async def handle_email(context, state, notification):
240-
email = notification.email
241-
if email:
242-
print(f"Received email: {email.id}")
243-
# Send a response
244-
response = EmailResponse.create_email_response_activity(
245-
"<p>Thank you for your email.</p>"
246-
)
247-
await context.send_activity(response)
248-
```
226+
>>> @notifications.on_email()
227+
... async def handle_email(context, state, notification):
228+
... email = notification.email
229+
... if email:
230+
... print(f"Received email: {email.id}")
231+
... response = EmailResponse.create_email_response_activity(
232+
... "<p>Thank you for your email.</p>"
233+
... )
234+
... await context.send_activity(response)
249235
"""
250236
return self.on_agent_notification(
251237
ChannelId(channel="agents", sub_channel=AgentSubChannel.EMAIL), **kwargs
@@ -266,13 +252,11 @@ def on_word(
266252
A decorator function that registers the handler with the application.
267253
268254
Example:
269-
```python
270-
@notifications.on_word()
271-
async def handle_word_comment(context, state, notification):
272-
comment = notification.wpx_comment
273-
if comment:
274-
print(f"Received Word comment: {comment.comment_id}")
275-
```
255+
>>> @notifications.on_word()
256+
... async def handle_word_comment(context, state, notification):
257+
... comment = notification.wpx_comment
258+
... if comment:
259+
... print(f"Received Word comment: {comment.comment_id}")
276260
"""
277261
return self.on_agent_notification(
278262
ChannelId(channel="agents", sub_channel=AgentSubChannel.WORD), **kwargs
@@ -293,13 +277,11 @@ def on_excel(
293277
A decorator function that registers the handler with the application.
294278
295279
Example:
296-
```python
297-
@notifications.on_excel()
298-
async def handle_excel_comment(context, state, notification):
299-
comment = notification.wpx_comment
300-
if comment:
301-
print(f"Received Excel comment: {comment.comment_id}")
302-
```
280+
>>> @notifications.on_excel()
281+
... async def handle_excel_comment(context, state, notification):
282+
... comment = notification.wpx_comment
283+
... if comment:
284+
... print(f"Received Excel comment: {comment.comment_id}")
303285
"""
304286
return self.on_agent_notification(
305287
ChannelId(channel="agents", sub_channel=AgentSubChannel.EXCEL), **kwargs
@@ -320,13 +302,11 @@ def on_powerpoint(
320302
A decorator function that registers the handler with the application.
321303
322304
Example:
323-
```python
324-
@notifications.on_powerpoint()
325-
async def handle_powerpoint_comment(context, state, notification):
326-
comment = notification.wpx_comment
327-
if comment:
328-
print(f"Received PowerPoint comment: {comment.comment_id}")
329-
```
305+
>>> @notifications.on_powerpoint()
306+
... async def handle_powerpoint_comment(context, state, notification):
307+
... comment = notification.wpx_comment
308+
... if comment:
309+
... print(f"Received PowerPoint comment: {comment.comment_id}")
330310
"""
331311
return self.on_agent_notification(
332312
ChannelId(channel="agents", sub_channel=AgentSubChannel.POWERPOINT), **kwargs
@@ -347,11 +327,9 @@ def on_lifecycle(
347327
A decorator function that registers the handler with the application.
348328
349329
Example:
350-
```python
351-
@notifications.on_lifecycle()
352-
async def handle_any_lifecycle_event(context, state, notification):
353-
print(f"Lifecycle event type: {notification.notification_type}")
354-
```
330+
>>> @notifications.on_lifecycle()
331+
... async def handle_any_lifecycle_event(context, state, notification):
332+
... print(f"Lifecycle event type: {notification.notification_type}")
355333
"""
356334
return self.on_lifecycle_notification("*", **kwargs)
357335

@@ -370,11 +348,9 @@ def on_user_created(
370348
A decorator function that registers the handler with the application.
371349
372350
Example:
373-
```python
374-
@notifications.on_user_created()
375-
async def handle_user_created(context, state, notification):
376-
print("New agentic user identity created")
377-
```
351+
>>> @notifications.on_user_created()
352+
... async def handle_user_created(context, state, notification):
353+
... print("New agentic user identity created")
378354
"""
379355
return self.on_lifecycle_notification(AgentLifecycleEvent.USERCREATED, **kwargs)
380356

@@ -393,11 +369,9 @@ def on_user_workload_onboarding(
393369
A decorator function that registers the handler with the application.
394370
395371
Example:
396-
```python
397-
@notifications.on_user_workload_onboarding()
398-
async def handle_onboarding_update(context, state, notification):
399-
print("User workload onboarding status updated")
400-
```
372+
>>> @notifications.on_user_workload_onboarding()
373+
... async def handle_onboarding_update(context, state, notification):
374+
... print("User workload onboarding status updated")
401375
"""
402376
return self.on_lifecycle_notification(
403377
AgentLifecycleEvent.USERWORKLOADONBOARDINGUPDATED, **kwargs
@@ -418,11 +392,9 @@ def on_user_deleted(
418392
A decorator function that registers the handler with the application.
419393
420394
Example:
421-
```python
422-
@notifications.on_user_deleted()
423-
async def handle_user_deleted(context, state, notification):
424-
print("Agentic user identity deleted")
425-
```
395+
>>> @notifications.on_user_deleted()
396+
... async def handle_user_deleted(context, state, notification):
397+
... print("Agentic user identity deleted")
426398
"""
427399
return self.on_lifecycle_notification(AgentLifecycleEvent.USERDELETED, **kwargs)
428400

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

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ class AgentNotificationActivity:
2828
activity: The underlying Activity object.
2929
3030
Example:
31-
```python
32-
async def email_handler(context: TurnContext, state: TurnState, notification: AgentNotificationActivity):
33-
email = notification.email
34-
if email:
35-
print(f"Received email: {email.id}")
36-
print(f"Body: {email.html_body}")
37-
```
31+
>>> async def email_handler(
32+
... context: TurnContext,
33+
... state: TurnState,
34+
... notification: AgentNotificationActivity,
35+
... ) -> None:
36+
... email = notification.email
37+
... if email:
38+
... print(f"Received email: {email.id}")
39+
... print(f"Body: {email.html_body}")
3840
"""
3941

4042
def __init__(self, activity: Activity):
@@ -158,17 +160,13 @@ def as_model(self, model: Type[TModel]) -> Optional[TModel]:
158160
An instance of the specified model type if validation succeeds, otherwise None.
159161
160162
Example:
161-
```python
162-
from pydantic import BaseModel
163-
164-
class CustomNotification(BaseModel):
165-
custom_field: str
166-
167-
notification = AgentNotificationActivity(activity)
168-
custom = notification.as_model(CustomNotification)
169-
if custom:
170-
print(custom.custom_field)
171-
```
163+
>>> from pydantic import BaseModel
164+
>>> class CustomNotification(BaseModel):
165+
... custom_field: str
166+
>>> notification = AgentNotificationActivity(activity)
167+
>>> custom = notification.as_model(CustomNotification)
168+
>>> if custom:
169+
... print(custom.custom_field)
172170
"""
173171
try:
174172
return model.model_validate(self.value or {})

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,10 @@ def create_email_response_activity(email_response_html_body: str) -> Activity:
3636
entity attached to its entities list.
3737
3838
Example:
39-
```python
40-
activity = EmailResponse.create_email_response_activity(
41-
"<p>Thank you for your email. I'll get back to you soon.</p>"
42-
)
43-
await context.send_activity(activity)
44-
```
39+
>>> activity = EmailResponse.create_email_response_activity(
40+
... "<p>Thank you for your email. I'll get back to you soon.</p>"
41+
... )
42+
>>> await context.send_activity(activity)
4543
"""
4644
working_activity = Activity(type="message")
4745
email_response = EmailResponse(html_body=email_response_html_body)

libraries/microsoft-agents-a365-observability-extensions-openai/microsoft_agents_a365/observability/extensions/openai/trace_instrumentor.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@
2222

2323

2424
class OpenAIAgentsTraceInstrumentor(BaseInstrumentor):
25-
"""
26-
Custom Trace Processor for OpenAI Agents SDK using Microsoft Agent 365.
27-
Forwards OpenAI Agents SDK traces and spans to Microsoft Agent 365's tracing scopes.
25+
"""Custom Trace Processor for OpenAI Agents SDK using Microsoft Agent 365.
2826
29-
```
27+
Forwards OpenAI Agents SDK traces and spans to Microsoft Agent 365's tracing scopes.
3028
"""
3129

3230
def __init__(self):

0 commit comments

Comments
 (0)