4444
4545if TYPE_CHECKING :
4646 from aiohttp .web_request import Request
47- from aiohttp .abc import AbstractMatchInfo
47+ from aiohttp .web_urldispatcher import UrlMappingMatchInfo
4848 from aiohttp import TraceRequestStartParams , TraceRequestEndParams
4949 from types import SimpleNamespace
5050 from typing import Any
5151 from typing import Dict
5252 from typing import Optional
5353 from typing import Tuple
54- from typing import Callable
5554 from typing import Union
5655
5756 from sentry_sdk .utils import ExcInfo
@@ -113,8 +112,9 @@ async def sentry_app_handle(self, request, *args, **kwargs):
113112 scope .clear_breadcrumbs ()
114113 scope .add_event_processor (_make_request_processor (weak_request ))
115114
115+ headers = dict (request .headers )
116116 transaction = continue_trace (
117- request . headers ,
117+ headers ,
118118 op = OP .HTTP_SERVER ,
119119 # If this transaction name makes it to the UI, AIOHTTP's
120120 # URL resolver did not find a route or died trying.
@@ -141,12 +141,12 @@ async def sentry_app_handle(self, request, *args, **kwargs):
141141 transaction .set_http_status (response .status )
142142 return response
143143
144- Application ._handle = sentry_app_handle
144+ Application ._handle = sentry_app_handle # type: ignore[method-assign]
145145
146146 old_urldispatcher_resolve = UrlDispatcher .resolve
147147
148148 async def sentry_urldispatcher_resolve (self , request ):
149- # type: (UrlDispatcher, Request) -> AbstractMatchInfo
149+ # type: (UrlDispatcher, Request) -> UrlMappingMatchInfo
150150 rv = await old_urldispatcher_resolve (self , request )
151151
152152 hub = Hub .current
@@ -173,12 +173,12 @@ async def sentry_urldispatcher_resolve(self, request):
173173
174174 return rv
175175
176- UrlDispatcher .resolve = sentry_urldispatcher_resolve
176+ UrlDispatcher .resolve = sentry_urldispatcher_resolve # type: ignore[method-assign]
177177
178178 old_client_session_init = ClientSession .__init__
179179
180180 def init (* args , ** kwargs ):
181- # type: (Any, Any) -> ClientSession
181+ # type: (Any, Any) -> None
182182 hub = Hub .current
183183 if hub .get_integration (AioHttpIntegration ) is None :
184184 return old_client_session_init (* args , ** kwargs )
@@ -190,7 +190,7 @@ def init(*args, **kwargs):
190190 kwargs ["trace_configs" ] = client_trace_configs
191191 return old_client_session_init (* args , ** kwargs )
192192
193- ClientSession .__init__ = init
193+ ClientSession .__init__ = init # type: ignore[method-assign]
194194
195195
196196def create_trace_config ():
@@ -253,7 +253,7 @@ async def on_request_end(session, trace_config_ctx, params):
253253
254254
255255def _make_request_processor (weak_request ):
256- # type: (Callable[[], Request]) -> EventProcessor
256+ # type: (weakref.ReferenceType[ Request]) -> EventProcessor
257257 def aiohttp_processor (
258258 event , # type: Dict[str, Any]
259259 hint , # type: Dict[str, Tuple[type, BaseException, Any]]
0 commit comments