Skip to content

Commit 17c6632

Browse files
chore(internal): add request options to SSE classes
1 parent 07f90be commit 17c6632

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/gitpod/_response.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
174174
),
175175
response=self.http_response,
176176
client=cast(Any, self._client),
177+
options=self._options,
177178
),
178179
)
179180

@@ -184,6 +185,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
184185
cast_to=extract_stream_chunk_type(self._stream_cls),
185186
response=self.http_response,
186187
client=cast(Any, self._client),
188+
options=self._options,
187189
),
188190
)
189191

@@ -197,6 +199,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
197199
cast_to=cast_to,
198200
response=self.http_response,
199201
client=cast(Any, self._client),
202+
options=self._options,
200203
),
201204
)
202205

src/gitpod/_streaming.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import json
55
import inspect
66
from types import TracebackType
7-
from typing import TYPE_CHECKING, Any, Generic, TypeVar, Iterator, AsyncIterator, cast
7+
from typing import TYPE_CHECKING, Any, Generic, TypeVar, Iterator, Optional, AsyncIterator, cast
88
from typing_extensions import Self, Protocol, TypeGuard, override, get_origin, runtime_checkable
99

1010
import httpx
@@ -13,6 +13,7 @@
1313

1414
if TYPE_CHECKING:
1515
from ._client import Gitpod, AsyncGitpod
16+
from ._models import FinalRequestOptions
1617

1718

1819
_T = TypeVar("_T")
@@ -22,7 +23,7 @@ class Stream(Generic[_T]):
2223
"""Provides the core interface to iterate over a synchronous stream response."""
2324

2425
response: httpx.Response
25-
26+
_options: Optional[FinalRequestOptions] = None
2627
_decoder: SSEBytesDecoder
2728

2829
def __init__(
@@ -31,10 +32,12 @@ def __init__(
3132
cast_to: type[_T],
3233
response: httpx.Response,
3334
client: Gitpod,
35+
options: Optional[FinalRequestOptions] = None,
3436
) -> None:
3537
self.response = response
3638
self._cast_to = cast_to
3739
self._client = client
40+
self._options = options
3841
self._decoder = client._make_sse_decoder()
3942
self._iterator = self.__stream__()
4043

@@ -85,7 +88,7 @@ class AsyncStream(Generic[_T]):
8588
"""Provides the core interface to iterate over an asynchronous stream response."""
8689

8790
response: httpx.Response
88-
91+
_options: Optional[FinalRequestOptions] = None
8992
_decoder: SSEDecoder | SSEBytesDecoder
9093

9194
def __init__(
@@ -94,10 +97,12 @@ def __init__(
9497
cast_to: type[_T],
9598
response: httpx.Response,
9699
client: AsyncGitpod,
100+
options: Optional[FinalRequestOptions] = None,
97101
) -> None:
98102
self.response = response
99103
self._cast_to = cast_to
100104
self._client = client
105+
self._options = options
101106
self._decoder = client._make_sse_decoder()
102107
self._iterator = self.__stream__()
103108

0 commit comments

Comments
 (0)