Skip to content

Commit

Permalink
feat: drop support for python 3.8 and drops deprecated type aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
andrueastman committed Jan 14, 2025
1 parent 49b2ea6 commit d5d925e
Show file tree
Hide file tree
Showing 23 changed files with 165 additions and 154 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
max-parallel: 5
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The Microsoft Graph Core Python Client Library contains core classes used by [Mi
## Prerequisites

Python 3.8+
Python 3.9+

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

Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ dependencies = [
"microsoft-kiota-http >=1.0.0,<2.0.0",
"httpx[http2] >=0.23.0",
]
requires-python = ">=3.8"
requires-python = ">=3.9"
license = {file = "LICENSE"}
readme = "README.md"
keywords = ["msgraph", "openAPI", "Microsoft", "Graph"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down
6 changes: 3 additions & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ httpx[http2]==0.28.1

hyperframe==6.0.1 ; python_full_version >= '3.6.1'

microsoft-kiota-abstractions==1.6.8
microsoft-kiota-abstractions==1.7.0

microsoft-kiota-authentication-azure==1.6.8
microsoft-kiota-authentication-azure==1.7.0

microsoft-kiota-http==1.6.8
microsoft-kiota-http==1.7.0

multidict==6.1.0 ; python_version >= '3.7'

Expand Down
2 changes: 1 addition & 1 deletion src/msgraph_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .authentication import AzureIdentityAuthenticationProvider
from .base_graph_request_adapter import BaseGraphRequestAdapter
from .graph_client_factory import GraphClientFactory
from .tasks import PageIterator
from .models import PageResult
from .tasks import PageIterator

__version__ = SDK_VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TYPE_CHECKING, Dict, List, Optional, Union
from typing import TYPE_CHECKING, Optional, Union

from kiota_authentication_azure.azure_identity_authentication_provider import (
AzureIdentityAuthenticationProvider as KiotaAzureIdentityAuthenticationProvider,
Expand All @@ -17,19 +17,19 @@ class AzureIdentityAuthenticationProvider(KiotaAzureIdentityAuthenticationProvid
def __init__(
self,
credentials: Union["TokenCredential", "AsyncTokenCredential"],
options: Optional[Dict] = {},
scopes: List[str] = [],
allowed_hosts: List[str] = [nc.value for nc in NationalClouds]
options: Optional[dict] = {},
scopes: list[str] = [],
allowed_hosts: list[str] = [nc.value for nc in NationalClouds]
) -> None:
"""[summary]
Args:
credentials (Union["TokenCredential", "AsyncTokenCredential"]): The
tokenCredential implementation to use for authentication.
options (Optional[dict]): The options to use for authentication.
scopes (List[str]): The scopes to use for authentication.
scopes (list[str]): The scopes to use for authentication.
Defaults to 'https://<national_cloud_domain>/.default'.
allowed_hosts (Optional[List[str]]): The allowed hosts to use for
allowed_hosts (Optional[list[str]]): The allowed hosts to use for
authentication. Defaults to Microsoft National Clouds.
"""
super().__init__(credentials, options, scopes, allowed_hosts)
1 change: 1 addition & 0 deletions src/msgraph_core/base_graph_request_adapter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Optional

import httpx
from kiota_abstractions.authentication import AuthenticationProvider
from kiota_abstractions.serialization import (
Expand Down
18 changes: 9 additions & 9 deletions src/msgraph_core/graph_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ------------------------------------
from __future__ import annotations

from typing import Dict, List, Optional
from typing import Optional

import httpx
from kiota_abstractions.request_option import RequestOption
Expand All @@ -27,7 +27,7 @@ def create_with_default_middleware( # type: ignore
api_version: APIVersion = APIVersion.v1,
client: Optional[httpx.AsyncClient] = None,
host: NationalClouds = NationalClouds.Global,
options: Optional[Dict[str, RequestOption]] = None
options: Optional[dict[str, RequestOption]] = None
) -> httpx.AsyncClient:
"""Constructs native HTTP AsyncClient(httpx.AsyncClient) instances configured with
a custom transport loaded with a default pipeline of middleware.
Expand All @@ -39,8 +39,8 @@ def create_with_default_middleware( # type: ignore
Defaults to KiotaClientFactory.get_default_client().
host (NationalClouds): The national clound endpoint to be used.
Defaults to NationalClouds.Global.
options (Optional[Dict[str, RequestOption]]): The request options to use when
instantiating default middleware. Defaults to Dict[str, RequestOption]=None.
options (Optional[dict[str, RequestOption]]): The request options to use when
instantiating default middleware. Defaults to dict[str, RequestOption]=None.
Returns:
httpx.AsyncClient: An instance of the AsyncClient object
Expand All @@ -56,15 +56,15 @@ def create_with_default_middleware( # type: ignore
@staticmethod
def create_with_custom_middleware( # type: ignore
# Breaking change to remove Kiota client factory as base class
middleware: Optional[List[BaseMiddleware]],
middleware: Optional[list[BaseMiddleware]],
api_version: APIVersion = APIVersion.v1,
client: Optional[httpx.AsyncClient] = None,
host: NationalClouds = NationalClouds.Global,
) -> httpx.AsyncClient:
"""Applies a custom middleware chain to the HTTP Client
Args:
middleware(List[BaseMiddleware]): Custom middleware list that will be used to create
middleware(list[BaseMiddleware]): Custom middleware list that will be used to create
a middleware pipeline. The middleware should be arranged in the order in which they will
modify the request.
api_version (APIVersion): The Graph API version to be used.
Expand All @@ -87,7 +87,7 @@ def _get_base_url(host: str, api_version: APIVersion) -> str:

@staticmethod
def _get_telemetry_handler(
options: Optional[Dict[str, RequestOption]]
options: Optional[dict[str, RequestOption]]
) -> GraphTelemetryHandler:
"""Helper method to get the graph telemetry handler instantiated with appropriate
options"""
Expand All @@ -102,7 +102,7 @@ def _get_telemetry_handler(

@staticmethod
def _load_middleware_to_client(
client: httpx.AsyncClient, middleware: Optional[List[BaseMiddleware]]
client: httpx.AsyncClient, middleware: Optional[list[BaseMiddleware]]
) -> httpx.AsyncClient:
current_transport = client._transport
client._transport = GraphClientFactory._replace_transport_with_custom_graph_transport(
Expand All @@ -123,7 +123,7 @@ def _load_middleware_to_client(

@staticmethod
def _replace_transport_with_custom_graph_transport(
current_transport: httpx.AsyncBaseTransport, middleware: Optional[List[BaseMiddleware]]
current_transport: httpx.AsyncBaseTransport, middleware: Optional[list[BaseMiddleware]]
) -> AsyncGraphTransport:
middleware_pipeline = KiotaClientFactory.create_middleware_pipeline(
middleware, current_transport
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Optional

from kiota_abstractions.request_option import RequestOption

Expand Down
2 changes: 1 addition & 1 deletion src/msgraph_core/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .page_result import PageResult
from .large_file_upload_session import LargeFileUploadSession
from .page_result import PageResult
from .upload_result import UploadResult, UploadSessionDataHolder

__all__ = ['PageResult', 'LargeFileUploadSession', 'UploadResult', 'UploadSessionDataHolder']
19 changes: 12 additions & 7 deletions src/msgraph_core/models/large_file_upload_session.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
from __future__ import annotations
from typing import Any, Callable, Dict, List, Optional

import datetime
from collections.abc import Callable
from dataclasses import dataclass, field
from typing import Any, Optional

from kiota_abstractions.serialization import (
AdditionalDataHolder, Parsable, ParseNode, SerializationWriter
AdditionalDataHolder,
Parsable,
ParseNode,
SerializationWriter,
)


@dataclass
class LargeFileUploadSession(AdditionalDataHolder, Parsable):

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

def get_field_deserializers(self, ) -> Dict[str, Callable[[ParseNode], None]]:
def get_field_deserializers(self, ) -> dict[str, Callable[[ParseNode], None]]:
"""
The deserialization information for the current model
Returns: Dict[str, Callable[[ParseNode], None]]
Returns: dict[str, Callable[[ParseNode], None]]
"""
fields: Dict[str, Callable[[Any], None]] = {
fields: dict[str, Callable[[Any], None]] = {
"expirationDateTime":
lambda n: setattr(self, 'expiration_date_time', n.get_datetime_value()),
"nextExpectedRanges":
Expand Down
13 changes: 7 additions & 6 deletions src/msgraph_core/models/page_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@
PageResult: Represents a page of items in a paged response.
"""
from __future__ import annotations
from typing import List, Optional, Dict, Callable, TypeVar

from collections.abc import Callable
from dataclasses import dataclass
from typing import Optional, TypeVar

from kiota_abstractions.serialization.parsable import Parsable
from kiota_abstractions.serialization.serialization_writer \
import SerializationWriter
from kiota_abstractions.serialization.parse_node import ParseNode
from kiota_abstractions.serialization.serialization_writer import SerializationWriter

T = TypeVar('T')


@dataclass
class PageResult(Parsable):
odata_next_link: Optional[str] = None
value: Optional[List[Parsable]] = None
value: Optional[list[Parsable]] = None

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

def get_field_deserializers(self) -> Dict[str, Callable[[ParseNode], None]]:
def get_field_deserializers(self) -> dict[str, Callable[[ParseNode], None]]:
"""Gets the deserialization information for this object.
Returns:
Dict[str, Callable[[ParseNode], None]]: The deserialization information for this
dict[str, Callable[[ParseNode], None]]: The deserialization information for this
object where each entry is a property key with its deserialization callback.
"""
return {
Expand Down
17 changes: 10 additions & 7 deletions src/msgraph_core/models/upload_result.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from typing import Any, Callable, Dict, List, Optional, TypeVar, Generic

from collections.abc import Callable
from dataclasses import dataclass
from datetime import datetime
from typing import Any, Generic, Optional, TypeVar

from kiota_abstractions.serialization import (
AdditionalDataHolder, Parsable, ParseNode, SerializationWriter
AdditionalDataHolder,
Parsable,
ParseNode,
SerializationWriter,
)

T = TypeVar('T')
Expand All @@ -13,16 +16,16 @@
@dataclass
class UploadSessionDataHolder(AdditionalDataHolder, Parsable):
expiration_date_time: Optional[datetime] = None
next_expected_ranges: Optional[List[str]] = None
next_expected_ranges: Optional[list[str]] = None
upload_url: Optional[str] = None
odata_type: Optional[str] = None

def get_field_deserializers(self, ) -> Dict[str, Callable[[ParseNode], None]]:
def get_field_deserializers(self, ) -> dict[str, Callable[[ParseNode], None]]:
"""
The deserialization information for the current model
Returns: Dict[str, Callable[[ParseNode], None]]
Returns: dict[str, Callable[[ParseNode], None]]
"""
fields: Dict[str, Callable[[Any], None]] = {
fields: dict[str, Callable[[Any], None]] = {
"expirationDateTime":
lambda n: setattr(self, 'expiration_date_time', n.get_datetime_value()),
"nextExpectedRanges":
Expand Down
18 changes: 9 additions & 9 deletions src/msgraph_core/requests/batch_request_builder.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import TypeVar, Type, Dict, Optional, Union
import logging
from typing import Optional, Type, TypeVar, Union

from kiota_abstractions.api_error import APIError
from kiota_abstractions.headers_collection import HeadersCollection
from kiota_abstractions.method import Method
from kiota_abstractions.request_adapter import RequestAdapter
from kiota_abstractions.request_information import RequestInformation
from kiota_abstractions.method import Method
from kiota_abstractions.serialization import Parsable, ParsableFactory
from kiota_abstractions.headers_collection import HeadersCollection
from kiota_abstractions.api_error import APIError

from .batch_request_content import BatchRequestContent
from .batch_request_content_collection import BatchRequestContentCollection
Expand All @@ -26,7 +26,7 @@ class BatchRequestBuilder:
def __init__(
self,
request_adapter: RequestAdapter,
error_map: Optional[Dict[str, Type[ParsableFactory]]] = None
error_map: Optional[dict[str, Type[ParsableFactory]]] = None
):
if request_adapter is None:
raise ValueError("request_adapter cannot be Null.")
Expand All @@ -37,15 +37,15 @@ def __init__(
async def post(
self,
batch_request_content: Union[BatchRequestContent, BatchRequestContentCollection],
error_map: Optional[Dict[str, Type[ParsableFactory]]] = None,
error_map: Optional[dict[str, Type[ParsableFactory]]] = None,
) -> Union[BatchResponseContent, BatchResponseContentCollection]:
"""
Sends a batch request and returns the batch response content.
Args:
batch_request_content (Union[BatchRequestContent,
BatchRequestContentCollection]): The batch request content.
Optional[Dict[str, Type[ParsableFactory]]] = None:
Optional[dict[str, Type[ParsableFactory]]] = None:
Error mappings for response handling.
Returns:
Expand Down Expand Up @@ -81,15 +81,15 @@ async def post(
async def _post_batch_collection(
self,
batch_request_content_collection: BatchRequestContentCollection,
error_map: Optional[Dict[str, Type[ParsableFactory]]] = None,
error_map: Optional[dict[str, Type[ParsableFactory]]] = None,
) -> BatchResponseContentCollection:
"""
Sends a collection of batch requests and returns a collection of batch response contents.
Args:
batch_request_content_collection (BatchRequestContentCollection): The
collection of batch request contents.
Optional[Dict[str, Type[ParsableFactory]]] = None:
Optional[dict[str, Type[ParsableFactory]]] = None:
Error mappings for response handling.
Returns:
Expand Down
Loading

0 comments on commit d5d925e

Please sign in to comment.