Skip to content

Commit d5d925e

Browse files
author
Andrew Omondi
committed
feat: drop support for python 3.8 and drops deprecated type aliases
1 parent 49b2ea6 commit d5d925e

23 files changed

+165
-154
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
max-parallel: 5
1919
matrix:
20-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
20+
python-version: ["3.9", "3.10", "3.11", "3.12"]
2121

2222
steps:
2323
- uses: actions/checkout@v4

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The Microsoft Graph Core Python Client Library contains core classes used by [Mi
1212
1313
## Prerequisites
1414

15-
Python 3.8+
15+
Python 3.9+
1616

1717
This library doesn't support [older](https://devguide.python.org/versions/) versions of Python.
1818

pyproject.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ dependencies = [
1616
"microsoft-kiota-http >=1.0.0,<2.0.0",
1717
"httpx[http2] >=0.23.0",
1818
]
19-
requires-python = ">=3.8"
19+
requires-python = ">=3.9"
2020
license = {file = "LICENSE"}
2121
readme = "README.md"
2222
keywords = ["msgraph", "openAPI", "Microsoft", "Graph"]
2323
classifiers = [
2424
"Development Status :: 5 - Production/Stable",
25-
"Programming Language :: Python :: 3.8",
2625
"Programming Language :: Python :: 3.9",
2726
"Programming Language :: Python :: 3.10",
2827
"Programming Language :: Python :: 3.11",

requirements-dev.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ httpx[http2]==0.28.1
145145

146146
hyperframe==6.0.1 ; python_full_version >= '3.6.1'
147147

148-
microsoft-kiota-abstractions==1.6.8
148+
microsoft-kiota-abstractions==1.7.0
149149

150-
microsoft-kiota-authentication-azure==1.6.8
150+
microsoft-kiota-authentication-azure==1.7.0
151151

152-
microsoft-kiota-http==1.6.8
152+
microsoft-kiota-http==1.7.0
153153

154154
multidict==6.1.0 ; python_version >= '3.7'
155155

src/msgraph_core/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .authentication import AzureIdentityAuthenticationProvider
1414
from .base_graph_request_adapter import BaseGraphRequestAdapter
1515
from .graph_client_factory import GraphClientFactory
16-
from .tasks import PageIterator
1716
from .models import PageResult
17+
from .tasks import PageIterator
1818

1919
__version__ = SDK_VERSION

src/msgraph_core/authentication/azure_identity_authentication_provider.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import TYPE_CHECKING, Dict, List, Optional, Union
1+
from typing import TYPE_CHECKING, Optional, Union
22

33
from kiota_authentication_azure.azure_identity_authentication_provider import (
44
AzureIdentityAuthenticationProvider as KiotaAzureIdentityAuthenticationProvider,
@@ -17,19 +17,19 @@ class AzureIdentityAuthenticationProvider(KiotaAzureIdentityAuthenticationProvid
1717
def __init__(
1818
self,
1919
credentials: Union["TokenCredential", "AsyncTokenCredential"],
20-
options: Optional[Dict] = {},
21-
scopes: List[str] = [],
22-
allowed_hosts: List[str] = [nc.value for nc in NationalClouds]
20+
options: Optional[dict] = {},
21+
scopes: list[str] = [],
22+
allowed_hosts: list[str] = [nc.value for nc in NationalClouds]
2323
) -> None:
2424
"""[summary]
2525
2626
Args:
2727
credentials (Union["TokenCredential", "AsyncTokenCredential"]): The
2828
tokenCredential implementation to use for authentication.
2929
options (Optional[dict]): The options to use for authentication.
30-
scopes (List[str]): The scopes to use for authentication.
30+
scopes (list[str]): The scopes to use for authentication.
3131
Defaults to 'https://<national_cloud_domain>/.default'.
32-
allowed_hosts (Optional[List[str]]): The allowed hosts to use for
32+
allowed_hosts (Optional[list[str]]): The allowed hosts to use for
3333
authentication. Defaults to Microsoft National Clouds.
3434
"""
3535
super().__init__(credentials, options, scopes, allowed_hosts)

src/msgraph_core/base_graph_request_adapter.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import Optional
2+
23
import httpx
34
from kiota_abstractions.authentication import AuthenticationProvider
45
from kiota_abstractions.serialization import (

src/msgraph_core/graph_client_factory.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# ------------------------------------
55
from __future__ import annotations
66

7-
from typing import Dict, List, Optional
7+
from typing import Optional
88

99
import httpx
1010
from kiota_abstractions.request_option import RequestOption
@@ -27,7 +27,7 @@ def create_with_default_middleware( # type: ignore
2727
api_version: APIVersion = APIVersion.v1,
2828
client: Optional[httpx.AsyncClient] = None,
2929
host: NationalClouds = NationalClouds.Global,
30-
options: Optional[Dict[str, RequestOption]] = None
30+
options: Optional[dict[str, RequestOption]] = None
3131
) -> httpx.AsyncClient:
3232
"""Constructs native HTTP AsyncClient(httpx.AsyncClient) instances configured with
3333
a custom transport loaded with a default pipeline of middleware.
@@ -39,8 +39,8 @@ def create_with_default_middleware( # type: ignore
3939
Defaults to KiotaClientFactory.get_default_client().
4040
host (NationalClouds): The national clound endpoint to be used.
4141
Defaults to NationalClouds.Global.
42-
options (Optional[Dict[str, RequestOption]]): The request options to use when
43-
instantiating default middleware. Defaults to Dict[str, RequestOption]=None.
42+
options (Optional[dict[str, RequestOption]]): The request options to use when
43+
instantiating default middleware. Defaults to dict[str, RequestOption]=None.
4444
4545
Returns:
4646
httpx.AsyncClient: An instance of the AsyncClient object
@@ -56,15 +56,15 @@ def create_with_default_middleware( # type: ignore
5656
@staticmethod
5757
def create_with_custom_middleware( # type: ignore
5858
# Breaking change to remove Kiota client factory as base class
59-
middleware: Optional[List[BaseMiddleware]],
59+
middleware: Optional[list[BaseMiddleware]],
6060
api_version: APIVersion = APIVersion.v1,
6161
client: Optional[httpx.AsyncClient] = None,
6262
host: NationalClouds = NationalClouds.Global,
6363
) -> httpx.AsyncClient:
6464
"""Applies a custom middleware chain to the HTTP Client
6565
6666
Args:
67-
middleware(List[BaseMiddleware]): Custom middleware list that will be used to create
67+
middleware(list[BaseMiddleware]): Custom middleware list that will be used to create
6868
a middleware pipeline. The middleware should be arranged in the order in which they will
6969
modify the request.
7070
api_version (APIVersion): The Graph API version to be used.
@@ -87,7 +87,7 @@ def _get_base_url(host: str, api_version: APIVersion) -> str:
8787

8888
@staticmethod
8989
def _get_telemetry_handler(
90-
options: Optional[Dict[str, RequestOption]]
90+
options: Optional[dict[str, RequestOption]]
9191
) -> GraphTelemetryHandler:
9292
"""Helper method to get the graph telemetry handler instantiated with appropriate
9393
options"""
@@ -102,7 +102,7 @@ def _get_telemetry_handler(
102102

103103
@staticmethod
104104
def _load_middleware_to_client(
105-
client: httpx.AsyncClient, middleware: Optional[List[BaseMiddleware]]
105+
client: httpx.AsyncClient, middleware: Optional[list[BaseMiddleware]]
106106
) -> httpx.AsyncClient:
107107
current_transport = client._transport
108108
client._transport = GraphClientFactory._replace_transport_with_custom_graph_transport(
@@ -123,7 +123,7 @@ def _load_middleware_to_client(
123123

124124
@staticmethod
125125
def _replace_transport_with_custom_graph_transport(
126-
current_transport: httpx.AsyncBaseTransport, middleware: Optional[List[BaseMiddleware]]
126+
current_transport: httpx.AsyncBaseTransport, middleware: Optional[list[BaseMiddleware]]
127127
) -> AsyncGraphTransport:
128128
middleware_pipeline = KiotaClientFactory.create_middleware_pipeline(
129129
middleware, current_transport

src/msgraph_core/middleware/options/graph_telemetry_handler_option.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, Optional
1+
from typing import Optional
22

33
from kiota_abstractions.request_option import RequestOption
44

src/msgraph_core/models/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from .page_result import PageResult
21
from .large_file_upload_session import LargeFileUploadSession
2+
from .page_result import PageResult
33
from .upload_result import UploadResult, UploadSessionDataHolder
44

55
__all__ = ['PageResult', 'LargeFileUploadSession', 'UploadResult', 'UploadSessionDataHolder']

src/msgraph_core/models/large_file_upload_session.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
from __future__ import annotations
2-
from typing import Any, Callable, Dict, List, Optional
2+
33
import datetime
4+
from collections.abc import Callable
45
from dataclasses import dataclass, field
6+
from typing import Any, Optional
57

68
from kiota_abstractions.serialization import (
7-
AdditionalDataHolder, Parsable, ParseNode, SerializationWriter
9+
AdditionalDataHolder,
10+
Parsable,
11+
ParseNode,
12+
SerializationWriter,
813
)
914

1015

1116
@dataclass
1217
class LargeFileUploadSession(AdditionalDataHolder, Parsable):
1318

14-
additional_data: Dict[str, Any] = field(default_factory=dict)
19+
additional_data: dict[str, Any] = field(default_factory=dict)
1520
expiration_date_time: Optional[datetime.datetime] = None
16-
next_expected_ranges: Optional[List[str]] = None
21+
next_expected_ranges: Optional[list[str]] = None
1722
is_cancelled: Optional[bool] = False
1823
odata_type: Optional[str] = None
1924
# The URL endpoint that accepts PUT requests for byte ranges of the file.
@@ -33,12 +38,12 @@ def create_from_discriminator_value(
3338
raise TypeError("parse_node cannot be null.")
3439
return LargeFileUploadSession()
3540

36-
def get_field_deserializers(self, ) -> Dict[str, Callable[[ParseNode], None]]:
41+
def get_field_deserializers(self, ) -> dict[str, Callable[[ParseNode], None]]:
3742
"""
3843
The deserialization information for the current model
39-
Returns: Dict[str, Callable[[ParseNode], None]]
44+
Returns: dict[str, Callable[[ParseNode], None]]
4045
"""
41-
fields: Dict[str, Callable[[Any], None]] = {
46+
fields: dict[str, Callable[[Any], None]] = {
4247
"expirationDateTime":
4348
lambda n: setattr(self, 'expiration_date_time', n.get_datetime_value()),
4449
"nextExpectedRanges":

src/msgraph_core/models/page_result.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,22 @@
1010
PageResult: Represents a page of items in a paged response.
1111
"""
1212
from __future__ import annotations
13-
from typing import List, Optional, Dict, Callable, TypeVar
13+
14+
from collections.abc import Callable
1415
from dataclasses import dataclass
16+
from typing import Optional, TypeVar
1517

1618
from kiota_abstractions.serialization.parsable import Parsable
17-
from kiota_abstractions.serialization.serialization_writer \
18-
import SerializationWriter
1919
from kiota_abstractions.serialization.parse_node import ParseNode
20+
from kiota_abstractions.serialization.serialization_writer import SerializationWriter
2021

2122
T = TypeVar('T')
2223

2324

2425
@dataclass
2526
class PageResult(Parsable):
2627
odata_next_link: Optional[str] = None
27-
value: Optional[List[Parsable]] = None
28+
value: Optional[list[Parsable]] = None
2829

2930
@staticmethod
3031
def create_from_discriminator_value(parse_node: Optional[ParseNode] = None) -> PageResult:
@@ -38,11 +39,11 @@ def create_from_discriminator_value(parse_node: Optional[ParseNode] = None) -> P
3839
raise TypeError("parse_node cannot be null")
3940
return PageResult()
4041

41-
def get_field_deserializers(self) -> Dict[str, Callable[[ParseNode], None]]:
42+
def get_field_deserializers(self) -> dict[str, Callable[[ParseNode], None]]:
4243
"""Gets the deserialization information for this object.
4344
4445
Returns:
45-
Dict[str, Callable[[ParseNode], None]]: The deserialization information for this
46+
dict[str, Callable[[ParseNode], None]]: The deserialization information for this
4647
object where each entry is a property key with its deserialization callback.
4748
"""
4849
return {

src/msgraph_core/models/upload_result.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
from typing import Any, Callable, Dict, List, Optional, TypeVar, Generic
2-
1+
from collections.abc import Callable
32
from dataclasses import dataclass
43
from datetime import datetime
4+
from typing import Any, Generic, Optional, TypeVar
55

66
from kiota_abstractions.serialization import (
7-
AdditionalDataHolder, Parsable, ParseNode, SerializationWriter
7+
AdditionalDataHolder,
8+
Parsable,
9+
ParseNode,
10+
SerializationWriter,
811
)
912

1013
T = TypeVar('T')
@@ -13,16 +16,16 @@
1316
@dataclass
1417
class UploadSessionDataHolder(AdditionalDataHolder, Parsable):
1518
expiration_date_time: Optional[datetime] = None
16-
next_expected_ranges: Optional[List[str]] = None
19+
next_expected_ranges: Optional[list[str]] = None
1720
upload_url: Optional[str] = None
1821
odata_type: Optional[str] = None
1922

20-
def get_field_deserializers(self, ) -> Dict[str, Callable[[ParseNode], None]]:
23+
def get_field_deserializers(self, ) -> dict[str, Callable[[ParseNode], None]]:
2124
"""
2225
The deserialization information for the current model
23-
Returns: Dict[str, Callable[[ParseNode], None]]
26+
Returns: dict[str, Callable[[ParseNode], None]]
2427
"""
25-
fields: Dict[str, Callable[[Any], None]] = {
28+
fields: dict[str, Callable[[Any], None]] = {
2629
"expirationDateTime":
2730
lambda n: setattr(self, 'expiration_date_time', n.get_datetime_value()),
2831
"nextExpectedRanges":

src/msgraph_core/requests/batch_request_builder.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from typing import TypeVar, Type, Dict, Optional, Union
21
import logging
2+
from typing import Optional, Type, TypeVar, Union
33

4+
from kiota_abstractions.api_error import APIError
5+
from kiota_abstractions.headers_collection import HeadersCollection
6+
from kiota_abstractions.method import Method
47
from kiota_abstractions.request_adapter import RequestAdapter
58
from kiota_abstractions.request_information import RequestInformation
6-
from kiota_abstractions.method import Method
79
from kiota_abstractions.serialization import Parsable, ParsableFactory
8-
from kiota_abstractions.headers_collection import HeadersCollection
9-
from kiota_abstractions.api_error import APIError
1010

1111
from .batch_request_content import BatchRequestContent
1212
from .batch_request_content_collection import BatchRequestContentCollection
@@ -26,7 +26,7 @@ class BatchRequestBuilder:
2626
def __init__(
2727
self,
2828
request_adapter: RequestAdapter,
29-
error_map: Optional[Dict[str, Type[ParsableFactory]]] = None
29+
error_map: Optional[dict[str, Type[ParsableFactory]]] = None
3030
):
3131
if request_adapter is None:
3232
raise ValueError("request_adapter cannot be Null.")
@@ -37,15 +37,15 @@ def __init__(
3737
async def post(
3838
self,
3939
batch_request_content: Union[BatchRequestContent, BatchRequestContentCollection],
40-
error_map: Optional[Dict[str, Type[ParsableFactory]]] = None,
40+
error_map: Optional[dict[str, Type[ParsableFactory]]] = None,
4141
) -> Union[BatchResponseContent, BatchResponseContentCollection]:
4242
"""
4343
Sends a batch request and returns the batch response content.
4444
4545
Args:
4646
batch_request_content (Union[BatchRequestContent,
4747
BatchRequestContentCollection]): The batch request content.
48-
Optional[Dict[str, Type[ParsableFactory]]] = None:
48+
Optional[dict[str, Type[ParsableFactory]]] = None:
4949
Error mappings for response handling.
5050
5151
Returns:
@@ -81,15 +81,15 @@ async def post(
8181
async def _post_batch_collection(
8282
self,
8383
batch_request_content_collection: BatchRequestContentCollection,
84-
error_map: Optional[Dict[str, Type[ParsableFactory]]] = None,
84+
error_map: Optional[dict[str, Type[ParsableFactory]]] = None,
8585
) -> BatchResponseContentCollection:
8686
"""
8787
Sends a collection of batch requests and returns a collection of batch response contents.
8888
8989
Args:
9090
batch_request_content_collection (BatchRequestContentCollection): The
9191
collection of batch request contents.
92-
Optional[Dict[str, Type[ParsableFactory]]] = None:
92+
Optional[dict[str, Type[ParsableFactory]]] = None:
9393
Error mappings for response handling.
9494
9595
Returns:

0 commit comments

Comments
 (0)