Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/abstractions/kiota_abstractions/request_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@
from abc import ABC, abstractmethod
from datetime import date, datetime, time, timedelta
from io import BytesIO
from typing import Generic, Optional, TypeVar, Union
from typing import Generic, Optional, Union
from uuid import UUID

from typing_extensions import TypeVar

from .request_information import RequestInformation
from .serialization import Parsable, ParsableFactory, SerializationWriterFactory
from .store import BackingStoreFactory

ResponseType = TypeVar("ResponseType")
ModelType = TypeVar("ModelType", bound=Parsable)
RequestType = TypeVar("RequestType")
RequestType_co = TypeVar("RequestType_co", covariant=True, default=object)
PrimitiveType = TypeVar(
"PrimitiveType", bool, str, int, float, UUID, datetime, timedelta, date, time, bytes
)


class RequestAdapter(ABC, Generic[RequestType]):
class RequestAdapter(ABC, Generic[RequestType_co]):
"""Service responsible for translating abstract Request Info into concrete native HTTP requests.
"""
# The base url for every request.
Expand Down Expand Up @@ -143,13 +145,13 @@ def enable_backing_store(self, backing_store_factory: Optional[BackingStoreFacto
pass

@abstractmethod
async def convert_to_native_async(self, request_info: RequestInformation) -> RequestType:
async def convert_to_native_async(self, request_info: RequestInformation) -> RequestType_co:
"""Translates the request information object into a native HTTP client request object.

Args:
request_info (RequestInformation): request information object to be converted.

Returns:
RequestType: the natively typed HTTP request of the client.
RequestType_co: the natively typed HTTP request of the client.
"""
pass
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from abc import abstractmethod
from typing import Generic, Optional, Protocol, TypeVar
from typing import Generic, Optional, Protocol

from typing_extensions import TypeVar

from .parsable import Parsable
from .parse_node import ParseNode

U_co = TypeVar("U_co", bound="Parsable", covariant=True)
U_co = TypeVar("U_co", bound="Parsable", covariant=True, default="Parsable")


class ParsableFactory(Protocol, Generic[U_co]):
Expand Down
1 change: 1 addition & 0 deletions packages/abstractions/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies = [
"std-uritemplate>=2.0.0",
"opentelemetry-api>=1.27.0",
"opentelemetry-sdk>=1.27.0",
"typing-extensions>=4.4.0",
]

[project.urls]
Expand Down
2 changes: 1 addition & 1 deletion packages/http/httpx/kiota_http/httpx_request_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ async def send_async(
async def send_collection_async(
self,
request_info: RequestInformation,
parsable_factory: ParsableFactory,
parsable_factory: ParsableFactory[ModelType],
error_map: Optional[dict[str, type[ParsableFactory]]],
) -> Optional[list[ModelType]]:
"""Excutes the HTTP request specified by the given RequestInformation and returns the
Expand Down
1 change: 1 addition & 0 deletions tests/validation/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[tool.mypy]
warn_unused_configs = true
strict = true
files = "validation"

[tool.yapf]
Expand Down
Loading