Skip to content

Commit a3cc32c

Browse files
v-dharmarajvannatischcemateia
authored
updating communication shared code to use the isodate instead of the … (#42085)
* udpating communication shared code to use the isodate instead of the date util * fixing the tests * fix the test failure * Updated communications dependencies * Local transport import statements * Use fixed offsets instead of ZoneInfo to fix tests in all environments * addressing the comments * changing to zoneinfo as per the comments * Revert "changing to zoneinfo as per the comments" This reverts commit 3e2610d. --------- Co-authored-by: antisch <[email protected]> Co-authored-by: Cezara Mateiasi <[email protected]>
1 parent 59e03dc commit a3cc32c

File tree

48 files changed

+151
-97
lines changed

Some content is hidden

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

48 files changed

+151
-97
lines changed

sdk/communication/azure-communication-callautomation/azure/communication/callautomation/_shared/token_exchange.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from typing import Any, List, Optional
99
# pylint: disable=non-abstract-transport-import
1010
# pylint: disable=no-name-in-module
11-
from azure.core.pipeline.transport import RequestsTransport
11+
1212
from azure.core.credentials import AccessToken
1313
from azure.core.pipeline import Pipeline, PipelineResponse
1414
from azure.core.pipeline.policies import BearerTokenCredentialPolicy
@@ -50,6 +50,9 @@ def _create_pipeline_from_options(self, pipeline_transport):
5050
policies = [auth_policy, entra_token_guard_policy, retry_policy]
5151
if pipeline_transport:
5252
return Pipeline(policies=policies, transport=pipeline_transport)
53+
54+
from azure.core.pipeline.transport import RequestsTransport
55+
5356
return Pipeline(policies=policies, transport=RequestsTransport())
5457

5558
def exchange_entra_token(self) -> AccessToken:

sdk/communication/azure-communication-callautomation/azure/communication/callautomation/_shared/token_exchange_async.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from typing import Any, Optional, List
99
# pylint: disable=non-abstract-transport-import
1010
# pylint: disable=no-name-in-module
11-
from azure.core.pipeline.transport import AioHttpTransport
11+
1212
from azure.core.credentials import AccessToken
1313
from azure.core.pipeline import AsyncPipeline, PipelineResponse
1414
from azure.core.pipeline.policies import AsyncBearerTokenCredentialPolicy
@@ -50,6 +50,9 @@ def _create_pipeline_from_options(self, pipeline_transport):
5050
policies = [auth_policy, entra_token_guard_policy, retry_policy]
5151
if pipeline_transport:
5252
return AsyncPipeline(policies=policies, transport=pipeline_transport)
53+
54+
from azure.core.pipeline.transport import AioHttpTransport
55+
5356
return AsyncPipeline(policies=policies, transport=AioHttpTransport())
5457

5558
async def exchange_entra_token(self) -> AccessToken:

sdk/communication/azure-communication-callautomation/azure/communication/callautomation/_shared/token_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import json
99
from datetime import datetime, timezone
1010
from typing import Tuple, Any, List, Optional
11-
from dateutil import parser as dateutil_parser # type: ignore
11+
import isodate
1212
from azure.core.exceptions import HttpResponseError
1313

1414
TEAMS_EXTENSION_SCOPE_PREFIX = "https://auth.msft.communication.azure.com/"
@@ -54,7 +54,7 @@ def determine_endpoint_and_api_version(scopes: Optional[List[str]]) -> Tuple[str
5454
def parse_expires_on(expires_on, response):
5555
if isinstance(expires_on, str):
5656
try:
57-
expires_on_dt = dateutil_parser.parse(expires_on)
57+
expires_on_dt = isodate.parse_datetime(expires_on)
5858
expires_on_epoch = int(expires_on_dt.timestamp())
5959
return expires_on_epoch
6060
except Exception as exc:
@@ -84,7 +84,7 @@ def is_acs_token_cache_valid(response_cache):
8484
content = response_cache.http_response.text()
8585
data = json.loads(content)
8686
expires_on = data["accessToken"]["expiresOn"]
87-
expires_on_dt = dateutil_parser.parse(expires_on)
87+
expires_on_dt = isodate.parse_datetime(expires_on)
8888
return datetime.now(timezone.utc) < expires_on_dt
8989
except (KeyError, ValueError, json.JSONDecodeError):
9090
raise ValueError( # pylint: disable=W0707

sdk/communication/azure-communication-callautomation/dev_requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55
-e ../../servicebus/azure-servicebus
66
../../core/azure-core
77
aiohttp>=3.0
8-
python-dateutil>=2.8.1

sdk/communication/azure-communication-callautomation/setup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343
"Programming Language :: Python",
4444
"Programming Language :: Python :: 3 :: Only",
4545
"Programming Language :: Python :: 3",
46-
"Programming Language :: Python :: 3.8",
4746
"Programming Language :: Python :: 3.9",
4847
"Programming Language :: Python :: 3.10",
4948
"Programming Language :: Python :: 3.11",
5049
"Programming Language :: Python :: 3.12",
50+
"Programming Language :: Python :: 3.13",
5151
"License :: OSI Approved :: MIT License",
5252
],
5353
zip_safe=False,
@@ -59,15 +59,15 @@
5959
"azure.communication",
6060
]
6161
),
62-
python_requires=">=3.8",
62+
python_requires=">=3.9",
6363
include_package_data=True,
6464
package_data={
6565
"pytyped": ["py.typed"],
6666
},
6767
install_requires=[
68-
"msrest>=0.7.1",
69-
"azure-core>=1.29.5",
70-
"typing-extensions>=4.3.0",
68+
"isodate>=0.6.1",
69+
"azure-core>=1.30.0",
70+
"typing-extensions>=4.6.0",
7171
],
7272
project_urls={
7373
"Bug Reports": "https://github.com/Azure/azure-sdk-for-python/issues",

sdk/communication/azure-communication-chat/azure/communication/chat/_shared/token_exchange.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from typing import Any, List, Optional
99
# pylint: disable=non-abstract-transport-import
1010
# pylint: disable=no-name-in-module
11-
from azure.core.pipeline.transport import RequestsTransport
11+
1212
from azure.core.credentials import AccessToken
1313
from azure.core.pipeline import Pipeline, PipelineResponse
1414
from azure.core.pipeline.policies import BearerTokenCredentialPolicy
@@ -50,6 +50,9 @@ def _create_pipeline_from_options(self, pipeline_transport):
5050
policies = [auth_policy, entra_token_guard_policy, retry_policy]
5151
if pipeline_transport:
5252
return Pipeline(policies=policies, transport=pipeline_transport)
53+
54+
from azure.core.pipeline.transport import RequestsTransport
55+
5356
return Pipeline(policies=policies, transport=RequestsTransport())
5457

5558
def exchange_entra_token(self) -> AccessToken:

sdk/communication/azure-communication-chat/azure/communication/chat/_shared/token_exchange_async.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from typing import Any, Optional, List
99
# pylint: disable=non-abstract-transport-import
1010
# pylint: disable=no-name-in-module
11-
from azure.core.pipeline.transport import AioHttpTransport
11+
1212
from azure.core.credentials import AccessToken
1313
from azure.core.pipeline import AsyncPipeline, PipelineResponse
1414
from azure.core.pipeline.policies import AsyncBearerTokenCredentialPolicy
@@ -50,6 +50,9 @@ def _create_pipeline_from_options(self, pipeline_transport):
5050
policies = [auth_policy, entra_token_guard_policy, retry_policy]
5151
if pipeline_transport:
5252
return AsyncPipeline(policies=policies, transport=pipeline_transport)
53+
54+
from azure.core.pipeline.transport import AioHttpTransport
55+
5356
return AsyncPipeline(policies=policies, transport=AioHttpTransport())
5457

5558
async def exchange_entra_token(self) -> AccessToken:

sdk/communication/azure-communication-chat/azure/communication/chat/_shared/token_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import json
99
from datetime import datetime, timezone
1010
from typing import Tuple, Any, List, Optional
11-
from dateutil import parser as dateutil_parser # type: ignore
11+
import isodate
1212
from azure.core.exceptions import HttpResponseError
1313

1414
TEAMS_EXTENSION_SCOPE_PREFIX = "https://auth.msft.communication.azure.com/"
@@ -54,7 +54,7 @@ def determine_endpoint_and_api_version(scopes: Optional[List[str]]) -> Tuple[str
5454
def parse_expires_on(expires_on, response):
5555
if isinstance(expires_on, str):
5656
try:
57-
expires_on_dt = dateutil_parser.parse(expires_on)
57+
expires_on_dt = isodate.parse_datetime(expires_on)
5858
expires_on_epoch = int(expires_on_dt.timestamp())
5959
return expires_on_epoch
6060
except Exception as exc:
@@ -84,7 +84,7 @@ def is_acs_token_cache_valid(response_cache):
8484
content = response_cache.http_response.text()
8585
data = json.loads(content)
8686
expires_on = data["accessToken"]["expiresOn"]
87-
expires_on_dt = dateutil_parser.parse(expires_on)
87+
expires_on_dt = isodate.parse_datetime(expires_on)
8888
return datetime.now(timezone.utc) < expires_on_dt
8989
except (KeyError, ValueError, json.JSONDecodeError):
9090
raise ValueError( # pylint: disable=W0707
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
-e ../../../tools/azure-sdk-tools
22
-e ../azure-communication-identity
3-
aiohttp>=3.0
4-
python-dateutil>=2.8.1
3+
aiohttp>=3.0

sdk/communication/azure-communication-chat/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343
"Programming Language :: Python",
4444
"Programming Language :: Python :: 3 :: Only",
4545
"Programming Language :: Python :: 3",
46-
"Programming Language :: Python :: 3.8",
4746
"Programming Language :: Python :: 3.9",
4847
"Programming Language :: Python :: 3.10",
4948
"Programming Language :: Python :: 3.11",
5049
"Programming Language :: Python :: 3.12",
50+
"Programming Language :: Python :: 3.13",
5151
"License :: OSI Approved :: MIT License",
5252
],
5353
zip_safe=False,
@@ -59,7 +59,7 @@
5959
"azure.communication",
6060
]
6161
),
62-
python_requires=">=3.8",
62+
python_requires=">=3.9",
6363
include_package_data=True,
6464
package_data={
6565
"pytyped": ["py.typed"],

0 commit comments

Comments
 (0)