Skip to content

Commit e267d48

Browse files
committed
wip
1 parent 6241a2e commit e267d48

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

src/sentry/hybridcloud/apigateway/middleware.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ def __init__(self, get_response: Callable[[Request], HttpResponseBase]):
2222
if iscoroutinefunction(self.get_response):
2323
markcoroutinefunction(self)
2424

25-
def __call__(self, request: Request) -> HttpResponseBase:
25+
def __call__(self, request: Request) -> Any:
2626
if iscoroutinefunction(self):
2727
return self.__acall__(request)
2828
return self.get_response(request)
2929

3030
async def __acall__(self, request: Request) -> HttpResponseBase:
31-
return await self.get_response(request)
31+
return await self.get_response(request) # type: ignore[misc]
3232

3333
def process_view(
3434
self,
@@ -45,14 +45,14 @@ def _process_view_match(
4545
view_func: Callable[..., HttpResponseBase],
4646
view_args: tuple[str],
4747
view_kwargs: dict[str, Any],
48-
):
48+
) -> Any:
4949
#: we check if we're in an async or sync runtime once, then
5050
# overwrite the method with the actual impl.
5151
try:
5252
asyncio.get_running_loop()
53-
method = self._process_view_inner
53+
method = self._process_view_inner # type: ignore[assignment]
5454
except RuntimeError:
55-
method = self._process_view_sync
55+
method = self._process_view_sync # type: ignore[assignment]
5656
setattr(self, "_process_view_match", method)
5757
return method(request, view_func, view_args, view_kwargs)
5858

src/sentry/hybridcloud/apigateway/proxy.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import asyncio
88
import logging
9-
from collections.abc import AsyncGenerator
9+
from collections.abc import AsyncGenerator, AsyncIterator
1010
from urllib.parse import urljoin, urlparse
1111
from wsgiref.util import is_hop_by_hop
1212

@@ -85,7 +85,7 @@ def _adapt_response(response: httpx.Response, remote_url: str) -> StreamingHttpR
8585
return streamed_response
8686

8787

88-
async def _stream_request(body) -> AsyncGenerator[bytes]:
88+
async def _stream_request(body: AsyncIterator[bytes]) -> AsyncGenerator[bytes]:
8989
async for chunk in body:
9090
yield chunk
9191

@@ -159,7 +159,6 @@ async def proxy_cell_request(
159159
if settings.APIGATEWAY_PROXY_SKIP_RELAY and request.path.startswith("/api/0/relays/"):
160160
return StreamingHttpResponse(streaming_content="relay proxy skipped", status=404)
161161

162-
data: AsyncGenerator[bytes] | None = None
163162
if url_name == "sentry-api-0-organization-objectstore":
164163
if content_encoding:
165164
header_dict["Content-Encoding"] = content_encoding

src/sentry/objectstore/endpoints/organization.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from collections.abc import AsyncGenerator, Callable, Generator
3+
from collections.abc import Callable, Generator
44
from typing import Any
55
from urllib.parse import urlparse
66
from wsgiref.util import is_hop_by_hop
@@ -153,7 +153,7 @@ def stream_generator():
153153

154154
def get_raw_body_async(
155155
request: HttpRequest,
156-
) -> AsyncGenerator[bytes] | ChunkedEncodingAsyncDecoder | BodyWithLengthAiter | None:
156+
) -> BodyAsyncWrapper | ChunkedEncodingAsyncDecoder | BodyWithLengthAiter | None:
157157
if request.body:
158158
return BodyAsyncWrapper(request.body)
159159

@@ -278,6 +278,9 @@ def read(self, size: int = -1) -> bytes:
278278

279279

280280
class ChunkedEncodingAsyncDecoder(ChunkedEncodingDecoder):
281+
def __aiter__(self):
282+
return self
283+
281284
async def __anext__(self) -> bytes:
282285
if self._done:
283286
raise StopAsyncIteration

src/sentry/utils/http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from collections.abc import Collection, Iterator
4-
from typing import TYPE_CHECKING, Iterable, NamedTuple, TypeGuard, overload
4+
from typing import TYPE_CHECKING, Any, NamedTuple, TypeGuard, overload
55
from urllib.parse import quote, urljoin, urlparse
66

77
from asgiref.sync import sync_to_async
@@ -228,7 +228,7 @@ def is_using_customer_domain(request: HttpRequest) -> TypeGuard[_HttpRequestWith
228228

229229

230230
class BodyAsyncWrapper:
231-
def __init__(self, body: Iterable):
231+
def __init__(self, body: Any):
232232
self.body = [body] if isinstance(body, bytes) else body
233233

234234
def __aiter__(self):

0 commit comments

Comments
 (0)