File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
libraries/microsoft-agents-a365-runtime/microsoft_agents_a365/runtime Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 88"""
99
1010from __future__ import annotations
11- from importlib .metadata import version
1211
1312import platform
1413import uuid
14+ from importlib .metadata import PackageNotFoundError , version
1515from typing import Any , Optional
1616
1717import jwt
1818
1919
2020class 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 ""
Original file line number Diff line number Diff line change 33
44"""Unit tests for Utility class."""
55
6- import uuid
7- from unittest .mock import Mock
86import platform
97import re
8+ import uuid
9+ from unittest .mock import Mock
1010
1111import jwt
1212import 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 )
You can’t perform that action at this time.
0 commit comments