Skip to content

Commit a20ff7b

Browse files
author
Jesus Terrazas
committed
copilot comments
1 parent f35dcd3 commit a20ff7b

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

libraries/microsoft-agents-a365-runtime/microsoft_agents_a365/runtime/utility.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@
88
"""
99

1010
from __future__ import annotations
11-
from importlib.metadata import version
1211

1312
import platform
1413
import uuid
14+
from importlib.metadata import PackageNotFoundError, version
1515
from typing import Any, Optional
1616

1717
import jwt
1818

1919

2020
class Utility:
21-
_cached_version = None
22-
2321
"""
2422
Utility class providing common runtime operations for Agent 365.
2523
2624
This class contains static methods for token processing, agent identity resolution,
2725
and other utility functions used across the Agent 365 runtime.
2826
"""
2927

28+
_cached_version = None
29+
3030
@staticmethod
3131
def get_app_id_from_token(token: Optional[str]) -> str:
3232
"""
@@ -101,7 +101,7 @@ def get_user_agent_header(orchestrator: str = "") -> str:
101101
if Utility._cached_version is None:
102102
try:
103103
Utility._cached_version = version("microsoft-agents-a365-runtime")
104-
except Exception:
104+
except PackageNotFoundError:
105105
Utility._cached_version = "unknown"
106106

107107
orchestrator_part = f"; {orchestrator}" if orchestrator else ""

tests/runtime/test_utility.py

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

44
"""Unit tests for Utility class."""
55

6-
import uuid
7-
from unittest.mock import Mock
86
import platform
97
import re
8+
import uuid
9+
from unittest.mock import Mock
1010

1111
import jwt
1212
import pytest
@@ -135,7 +135,7 @@ def test_get_user_agent_header_default():
135135

136136
result = Utility.get_user_agent_header()
137137

138-
# Regex for Agent365SDK/version (OS; Python/version)
138+
# Regex for Agent365SDK/version (OS; Python version)
139139
pattern = rf"^Agent365SDK/.+ \({os_type}; Python {py_version}\)$"
140140
assert re.match(pattern, result)
141141

@@ -148,6 +148,6 @@ def test_get_user_agent_header_with_orchestrator():
148148

149149
result = Utility.get_user_agent_header(orchestrator)
150150

151-
# Regex for Agent365SDK/version (OS; Python/version; TestOrchestrator)
151+
# Regex for Agent365SDK/version (OS; Python version; TestOrchestrator)
152152
pattern = rf"^Agent365SDK/.+ \({os_type}; Python {py_version}; {orchestrator}\)$"
153153
assert re.match(pattern, result)

0 commit comments

Comments
 (0)