Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
szokeasaurusrex committed Jul 10, 2024
1 parent 0eafa2e commit a017237
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 2 additions & 3 deletions sentry_sdk/integrations/sanic.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@
from typing import Callable
from typing import Optional
from typing import Union
from typing import Tuple
from typing import Dict

from sanic.request import Request, RequestParameters
from sanic.response import BaseHTTPResponse

from sentry_sdk._types import Event, EventProcessor, Hint
from sentry_sdk._types import Event, EventProcessor, ExcInfo, Hint
from sanic.router import Route

try:
Expand Down Expand Up @@ -325,7 +324,7 @@ def _legacy_router_get(self, *args):

@ensure_integration_enabled(SanicIntegration)
def _capture_exception(exception):
# type: (Union[Tuple[Optional[type], Optional[BaseException], Any], BaseException]) -> None
# type: (Union[ExcInfo, BaseException]) -> None
with capture_internal_exceptions():
event, hint = event_from_exception(
exception,
Expand Down
10 changes: 7 additions & 3 deletions sentry_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from decimal import Decimal
from functools import partial, partialmethod, wraps
from numbers import Real
from typing import cast
from urllib.parse import parse_qs, unquote, urlencode, urlsplit, urlunsplit

try:
Expand All @@ -28,6 +29,7 @@
import sentry_sdk
import sentry_sdk.hub
from sentry_sdk._compat import PY37
from sentry_sdk._types import ExcInfo # This type must be available at runtime!
from sentry_sdk._types import TYPE_CHECKING
from sentry_sdk.consts import DEFAULT_MAX_VALUE_LENGTH, EndpointType

Expand All @@ -38,7 +40,6 @@
from typing import (
Any,
Callable,
cast,
ContextManager,
Dict,
Iterator,
Expand All @@ -57,7 +58,7 @@
from gevent.hub import Hub

import sentry_sdk.integrations
from sentry_sdk._types import Event, ExcInfo
from sentry_sdk._types import Event

P = ParamSpec("P")
R = TypeVar("R")
Expand Down Expand Up @@ -1012,7 +1013,10 @@ def exc_info_from_error(error):
else:
raise ValueError("Expected Exception object to report, got %s!" % type(error))

return exc_type, exc_value, tb
# This cast is safe because exc_type and exc_value are either both
# None or both not None.
exc_info = cast(ExcInfo, (exc_type, exc_value, tb))
return exc_info


def event_from_exception(
Expand Down

0 comments on commit a017237

Please sign in to comment.