Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix-linter
  • Loading branch information
Gleekzone committed Sep 9, 2020
commit a25e324c2ce55326c825ed93f3135bba21f3b3a5
2 changes: 2 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ ignore_missing_imports = True
ignore_missing_imports = True
[mypy-pure_eval.*]
ignore_missing_imports = True
[mypy-chalice.*]
ignore_missing_imports = True
19 changes: 16 additions & 3 deletions sentry_sdk/integrations/chalice.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,21 @@
capture_internal_exceptions,
event_from_exception,
)
from sentry_sdk._types import MYPY

if MYPY:
from typing import Any
from typing import TypeVar
from typing import Callable

F = TypeVar("F", bound=Callable[..., Any])


class EventSourceHandler(ChaliceEventSourceHandler):
def __call__(self, event, context):
# type: (Any, Any) -> Any
hub = Hub.current
client = hub.client
client = hub.client # type: Any

with hub.push_scope() as scope:
with capture_internal_exceptions():
Expand All @@ -41,10 +50,12 @@ def __call__(self, event, context):


def _get_view_function_response(app, view_function, function_args):
# type: (Any, F, Any) -> F
@wraps(view_function)
def wrapped_view_function(**function_args):
# type: (**Any) -> Any
hub = Hub.current
client = hub.client
client = hub.client # type: Any
with hub.push_scope() as scope:
with capture_internal_exceptions():
configured_time = app.lambda_context.get_remaining_time_in_millis()
Expand All @@ -71,17 +82,19 @@ def wrapped_view_function(**function_args):
hub.flush()
raise

return wrapped_view_function
return wrapped_view_function # type: ignore


class ChaliceIntegration(Integration):
identifier = "chalice"

@staticmethod
def setup_once():
# type: () -> None
old_get_view_function_response = Chalice._get_view_function_response

def sentry_event_response(app, view_function, function_args):
# type: (Any, F, **Any) -> Any
wrapped_view_function = _get_view_function_response(
app, view_function, function_args
)
Expand Down